Reputation: 5197
When OptionsMenu is clicked, I want to show the dialog that has 3 radio buttons in it.
Then each of 3 transactions will be fired depending on which chosen.
How can I do that?
I have 2 OptionsMenu such as about
and select
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/about"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/about"/>
<item
android:id="@+id/select"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/select"/>
</menu>
My current code is this
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.about:
new AlertDialog.Builder(this).setTitle("About").setMessage("Text about about").setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// continue with delete
}
}).show();
break;
case R.id.select:
// What comes here?!?!?!?
}
return true;
}
}
Upvotes: 0
Views: 64
Reputation: 2933
Here are some examples how to do it.
You need to create your own custom dialog to achieve what you want.
http://www.helloandroid.com/tutorials/how-display-custom-dialog-your-android-application
Upvotes: 1