Monday 15 August 2011

android - AlertDialog style and color -



android - AlertDialog style and color -

i trying create alert dialog this

but can't figure out why, when launch app on device dialog looking this:

i followed many tutorials , still got alert dialog looking that. code pretty standard not gonna post it, if required will. device running on 4.3 android. question: alert style alter device api lvl? if can create dialog on first pic? create custom dialog layout inflater, want have cool buttons.

the issue themes.

the dialog first screenshot uses "holo light" theme, while sec 1 uses "theme" theme.

you have 2 options creating alertdialog 1 in first picture.

you can alter theme application or activity inherit holo.light (see android's styles & themes guide). alter appearance of alertdialogs across entire application or activity.

you can set theme individual alertdialog in next manner:

new alertdialog.builder(new contextthemewrapper(this, android.r.style.theme_holo_light_dialog)) .settitle("demo dialog") .setmessage("this alertdialog uses theme android.r.style.theme_holo_light_dialog.") .create() .show();

either of these options produce next result:

android styles android-alertdialog

No comments:

Post a Comment