Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Hmmm, I suspect the dialog is running in a different thread? Well anyway if you use one and alert dialog they have DialogInterface.onClickListener class that handles that, there may be a better way to overcome the problem, but changing the code to and actual custom dialog fixes this. </p> <p>Here is your original code modified with that fix, this is probably better anyway since you can then put the dialog in it's own file/class etc. </p> <pre><code>public class BtnNoWorky extends Activity { private int action; private Button btnCopyNext; private Button btnNext; private Button btnQuit; private final int SVC_MENU_DIALOG = 1; private final String MY_LABEL = "BtnNoWorky"; private final String MESSAGE1 = "Msg from onCreateDialog"; private final String MESSAGE2 = "Msg from onPrepare"; private myDialog D = null; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { Log.d(MY_LABEL, "onCreate()"); super.onCreate(savedInstanceState); Log.d(MY_LABEL, "Show dialog") ; //showDialog(SVC_MENU_DIALOG); D = new myDialog(this); D.show(); Log.d(MY_LABEL, "showDialog() has completed."); } public class myDialog extends Dialog implements OnClickListener { public myDialog(Context context) { super(context,0); } public myDialog(Context context, int theme) { super(context, theme); } protected myDialog(Context context, boolean cancelable, OnCancelListener cancelListener) { super(context, cancelable, cancelListener); // TODO Auto-generated constructor stub } public void onCreate(Bundle saved) { //Log.d(MY_LABEL, "onCreateDialog - Creating dialog"); //Log.d(MY_LABEL, "onCreateDialog - setContentView"); setContentView(R.layout.bnw_dialog); //Log.d(MY_LABEL, "onCreateDialog - setTitle"); setTitle("BtnNoWorky"); //Log.d(MY_LABEL, "onCreateDialog - setText"); TextView text = (TextView) findViewById(R.id.text); text.setText(MESSAGE1); //Log.d(MY_LABEL, "onCreateDialog - setImageResource"); ImageView image = (ImageView) findViewById(R.id.icon); image.setImageResource(R.drawable.icon); //Log.d(MY_LABEL, "onCreateDialog - Instantiate btnCopyNext"); btnCopyNext = (Button)findViewById(R.id.BtnCopyNext); btnCopyNext.setOnClickListener(this); //Log.d(MY_LABEL, "onCreateDialog - Instantiate btnNext"); btnNext = (Button) findViewById(R.id.BtnNext); btnNext.setOnClickListener(this); //Log.d(MY_LABEL, "onCreateDialog - Instantiate btnQuit"); btnQuit = (Button)findViewById(R.id.BtnQuit); btnQuit.setOnClickListener(this); //Log.d(MY_LABEL, "onCreateDialog - Returning..."); } @Override public void onClick(View v) { action = v.getId() ; Toast.makeText(getApplicationContext() , "Button " + action + " clicked." , Toast.LENGTH_SHORT).show(); Log.d(MY_LABEL, "Button " + action + " clicked."); dismiss(); } } } </code></pre>
    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.
 

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