I want to set AlertDialogue
theme or change background color.
Though I know it has a default theme but in different version I am getting different theme so I want to fix it for all version.
Or simply change background color as white
@NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
final SimpleAdapter adapter = new SimpleAdapter(getContext(), imagesWithNames, R.layout.lib_dialog_image,
new String[]{"name", "imageID","Spacing"}, new int[]{R.id.text1, R.id.image1,R.id.spacing});
return new AlertDialog.Builder(getContext()).setAdapter(adapter,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
((PlaceCallActivity) getContext()).OnSelected(WithNamesFragment.this.getClass(), (int) ((HashMap<String, Object>) adapter.getItem(i)).get("imageID"));
}
}).setCancelable(true).setTitle("PICK YOUR AVATAR").setNegativeButton("Cancel",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
}).create();
}
Don't post your code please tell where I should make a change here.
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.AlertDialogCustom));
Note : The Above line would do it but I want to know where I should give style for my AlertDialogue
Create your style in your
styles.xml
file as follows.Then Create
Alert Dialog
using Builder as followsHere passing the current class Context and style to the
ContextThemeWrapper
class constructor.You should add dialog style inside res/values/styles.xml. Like as below.
Or you change background color as below also:
EDIT: