Reputation: 303
I am trying to add custom views(chekbox and two radio buttons) as shown in image below in alertdialog but not succeded.
Please suggest me a way to get views as shown in the image.
Thanks in advance!!
Upvotes: 0
Views: 2664
Reputation: 3211
Use DialogFragment instead of AlertDialog.
public class CustomDialogFragment extends DialogFragment {
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = LayoutInflater.from(getActivity());
View viewRoot = inflater.inflate(R.layout.dialog_view, null);
//do something with your view
builder.setView(viewRoot);
return builder.create();
}
}
R.layout.dialog_view
- it's your view, which you want to display
Upvotes: 2
Reputation: 356
You can build dialog with custom layout.
Here's some tutorial how to do that:
http://www.mkyong.com/android/android-custom-dialog-example/
Upvotes: 0