Reputation: 17119
I'm trying to set up a RadioGroup inside an AlertDialog. I'm using the following construct for that.
new AlertDialog.Builder(this)
.setTitle("Set icon for " + item_cursor.getString(1))
.setView(radioGroupView)
.setPositiveButton("Ok",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
RadioGroup radioGroup = (RadioGroup) findViewById(R.id.radiogroup);
int checkedRadioButton = 0;
try {
checkedRadioButton = radioGroup.getCheckedRadioButtonId();
} catch (Exception e) {
e.printStackTrace();
}
int i =0;
switch (checkedRadioButton) {
case R.id.a2s :
datasource.updateIcon(i,itemid);
break;
case R.id.android: i=1;
datasource.updateIcon(i,itemid);
break;
}
}
}).setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
// Canceled.
}
}).show();
But the alertDialog only shows one Radiobutton. Following is the XML seticon.xml :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">
<RadioGroup android:layout_width="fill_parent"
android:layout_height="wrap_content" android:orientation="horizontal"
android:id="@+id/radiogroup">
<RadioButton android:id="@+id/android"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:text="Android" />
<RadioButton android:id="@+id/a2s" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="Argen2Stone ROM" />
</RadioGroup>
</LinearLayout>
Why does this happen?
Upvotes: 0
Views: 3688
Reputation: 20567
Try changing the height to wrap content on both the radio group and also the linear layout.
Upvotes: 2