I have following code for alertdialog:
AlertDialog.Builder helpBuilder = new AlertDialog.Builder(this);
helpBuilder.setTitle("Options");
helpBuilder.setMessage("Choose Your Option");
LayoutInflater inflater = getLayoutInflater();
View radioButtonLayout = inflater.inflate(R.layout.popuplayout, null);
byNameRadioButton = (RadioButton) findViewById(R.id.byname);
byIdRadioButton = (RadioButton) findViewById(R.id.byid);
helpBuilder.setView(radioButtonLayout);
helpBuilder.setPositiveButton("Ok",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(Tab1Activity.this,
"Ok button is clicked", Toast.LENGTH_LONG)
.show();
}
}
});
AlertDialog helpDialog = helpBuilder.create();
helpDialog.show();

I want to know which radiobutton was clicked when ok OK button is clicked ??
Help Needed.
Thanx !
Why don’t you use the default implementation of Dialog with radio buttons which you can find here : Dialogs . You won’t need to write anything extra as code and you will get what you need! : )
Here is the example :