Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code>public class MainActivity extends Activity { private Button button1,button2,button3; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); button1 = (Button) findViewById(R.id.button1); button2 = (Button) findViewById(R.id.button2); button3 = (Button) findViewById(R.id.button3); /* * Implementation for dynamic OnClicklisteners */ // button1.setOnClickListener(new OnClickListener(){ // @Override // public void onClick(View v) { // openDialog(v); // } // }); // button2.setOnClickListener(new OnClickListener(){ // @Override // public void onClick(View v) { // openDialog(v); // } // }); // button3.setOnClickListener(new OnClickListener(){ // @Override // public void onClick(View v) { // openDialog(v); // } // }); } public void openDialog(View v){ AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(MainActivity.this) .setTitle("Settings Menu") .setMessage("Delete Edit or Link?") .setCancelable(false) .setNeutralButton("Edit", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog,int id) { Toast.makeText(MainActivity.this, "Clicked Edit",Toast.LENGTH_LONG).show(); } }) .setPositiveButton("Link",new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog,int id) { Toast.makeText(MainActivity.this, "Clicked Link",Toast.LENGTH_LONG).show(); } }) .setNegativeButton("Delete",new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog,int id) { dialog.cancel(); } }); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); } &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/linearLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#FFF" android:orientation="vertical" &gt; &lt;TextView android:textAppearance="?android:textAppearanceLarge" android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" /&gt; &lt;Button android:id="@+id/button1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Core Device 1" android:onClick="openDialog" /&gt; &lt;Button android:id="@+id/button2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Core Device 2" android:onClick="openDialog" /&gt; &lt;Button android:id="@+id/button3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Core Device 3" android:onClick="openDialog" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>You can see the source at <a href="https://github.com/darussian/SimpleAndroidDialogExample" rel="nofollow">https://github.com/darussian/SimpleAndroidDialogExample</a></p>
 

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