HUSTEN
HUSTEN

Reputation: 5197

How can I show the dialog that has three radio buttons?

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

Answers (1)

JanBo
JanBo

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

Android: Custom AlertDialog

http://overoid.tistory.com/29

Upvotes: 1

Related Questions