title: Updating a textview inside a custom dialog via a button
body: <p>So, my current issue is that I can't find an elegant way to update a dialog box when a button is pressed.  I can achieve functionally the same result by dismiss() and show(), but that is ugly.</p>
  
  <p>Lets say this dialog has 3 buttons, for selling widgets that the player has.  Sell All, Sell 10, and Sell X (amount entered with a EditText).  I'd like for the dialog to persist if the player pushes Sell 10, but also to update it's textviews with the new count of widgets.</p>
  
  <p>Pertinent part of the XML layout of the custom dialog:</p>
  
  <pre><code>&lt;LinearLayout android:id="@+id/linearLayout3" android:layout_height="wrap_content" android:layout_width="match_parent"&gt;
          &lt;TextView android:id="@+id/sell10Text" android:layout_width="wrap_content" android:text="TextView" android:layout_height="wrap_content" android:layout_weight="2"&gt;&lt;/TextView&gt;
          &lt;Button android:text="Sell 10" android:enabled="false" android:layout_width="wrap_content" android:id="@+id/sell10Button" android:layout_height="wrap_content" android:layout_weight="1"&gt;&lt;/Button&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Pertinent part of the dialog creation:</p>
  
  <pre><code>final Dialog alert = new Dialog(this);  
      alert.setTitle("Sell how many "+(masterRes.get(currentResIndex).getName())+"?");
      alert.setContentView(R.layout.selldialog);
  
      TextView tvsellAll = (TextView) alert.findViewById(R.id.sellAllText);
      TextView tvsell10 = (TextView) alert.findViewById(R.id.sell10Text);
  
              //etc etc more handles, including buttons
  
      tvsellAll.setText("Sell All ("+String.valueOf(masterRes.get(currentResIndex).getHeld())+") - $"+String.valueOf(calcCost(masterRes.get(currentResIndex).getHeld())));
      tvsell10.setText("Sell 10 - $"+String.valueOf(calcCost(10)));
  
                 // etc etc more setTexts
  
      btnsell10.setOnClickListener( new OnClickListener() {
              public void onClick(View v) {
                 if (v.isEnabled()) {
                     int y=masterRes.get(currentResIndex).getHeld();
                     masterRes.get(currentResIndex).setHeld(y-10);
                     held -= 10;
  
                     money += (calcCost(10));
  
  
                     updateScreen();
                     alert.tvsellAll.setText("Sell All ("+String.valueOf(masterRes.get(currentResIndex).getHeld())+") - $"+String.valueOf(calcCost(masterRes.get(currentResIndex).getHeld())));
                     alert.tvsell10.setText("Sell 10 - $"+String.valueOf(calcCost(10)));
                     alert.tvsellAmt.setText("Sell Amount (0-"+String.valueOf(masterRes.get(currentResIndex).getHeld())+")");
  
  
                 }
              }
          });
              // etc etc other button handlers, alert.show() at the end
  </code></pre>
  
  <p>Now obviously the setTexts within the button can't resolve, as they can't see the alert I created, they just see OnClickListener.</p>
  
  <p>I tried handling this like I did with my main activity's updater updateScreen(), which is a <code>Runnable</code>, that is a long list of setTexts and/or invalidates, and is <code>runOnUiThread(updateScreen)</code>.  Works great for the base activity.  </p>
  
  <p>I did some copypasta and tried to make a updateSellScreen(), get it to hook into the custom dialog's textviews, but it can't resolve the alert class...  I'm kind of lost now.</p>
  
  <p>Is this even possible without trashing everything and just creating a custom view (which I am very averse to trying to tackle this fresh into Android programming...)</p>