Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to overload button callback in AlertDialog
    primarykey
    data
    text
    <p>I wan't to create a dialog item, with the same look&amp;feel (<a href="http://wptrafficanalyzer.in/blog/wp-content/uploads/2012/07/open_alert_dialog_screenshot.png" rel="nofollow">like this one</a>) as AlertDialog, but where the button have a personalised callback.</p> <p>I've tried to create an AlertDialog like that :</p> <p><code>AlertDialog.Builder adb = new AlertDialog.Builder(SearchActivity.this); AlertDialog d = adb.setView(relativeLayout).create();</code> [..] </p> <pre><code> WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(d.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.MATCH_PARENT; lp.height = WindowManager.LayoutParams.MATCH_PARENT; </code></pre> <p>[....]</p> <pre><code> d.setButton(-1, "Retour", new AlertDialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); d.setButton(-2, "Description", new AlertDialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { videoView.setVisibility(View.INVISIBLE); browser.setVisibility(View.VISIBLE); } }); d.setButton(-3, "Video", new AlertDialog.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { videoView.setVisibility(View.VISIBLE); browser.setVisibility(View.INVISIBLE); } });` </code></pre> <p>When I click on the video button, or the description button, the dialog is automatically closed. I know that using a AlertDialog for this is not the best idea, but I'm don't have time to learn how to use fragments.</p> <p>How could I prevent the dialog to close? </p>
    singulars
    1. This table or related slice is empty.
    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.
 

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