Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I would use the methods onCreateDialog() and onPrepareDialog(). By doing this, you get a lot more control over when dialogs get populated and shown.</p> <p>onCreateDialog() fires when the dialog is shown for the first time. This method is the one to setup your dialog in.</p> <p>onPrepareDialog() fires right before it is shown each time. This method is the one to change options in each subsequent time.</p> <pre><code>@Override protected Dialog onCreateDialog(int id) { super.onCreateDialog(id); final Dialog dialog = new Dialog(UserStatsActivity.this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.createuserrow); dialog.setOnDismissListener(this); //set up button Button button = (Button) dialog.findViewById(R.id.saveUser); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { TextView nameTextView = (TextView)dialog.findViewById(R.id.userName); userNickName = nameTextView.getText().toString().trim(); if ((userNickName.length() &gt; 0) &amp;&amp; (userNickName.length() &lt; 9)){ saveUser = true; dialog.dismiss(); } } }); //now that the dialog is set up, it's time to show it return dialog; } </code></pre> <p>This is how the onCreateDialog(int id) method could be used in your case. Now, keep in mind that above, I did not take into account any other dialogs that you could create, so you should assign a constant Int to your Dialog and determine from within this method.</p> <p>Also keep in mind the fact that this method <strong>only</strong> gets called the first dialog. You must use:</p> <pre><code>@Override protected void onPrepareDialog(int id, Dialog dialog, Bundle args) { super.onPrepareDialog(id, dialog, args); if(id == DIALOG_DEFAULT) { dialog.setTitle(mSettings.getString(getString(R.string.key_due_date), getString(R.string.unknown_task))); ((AlertDialog)dialog).setMessage(mSettings.getString(getString(R.string.key_task), getString(R.string.unknown_task))); } } </code></pre> <p>To repopulate for each subsequent dialog, or add <code>removeDialog(int DIALOG_ID);</code> to your onClick.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload