android - Why isn't my EditText styled to match my AlertDialog? -


i trying create alertdialog single text field prompt. here code using create it:

final edittext url = new edittext(this); new alertdialog.builder(this, alertdialog.theme_device_default_dark)   .settitle(r.string.mirror_title)   .setview(url)   .setpositivebutton(...)   .setnegativebutton(...)   .show(); 

when run against api level 22, buttons style using material expected, edittext not:

dialog old-style text input

what need new style edittext here?

you specifying @android:style/theme.devicedefault alert dialog theme, edittext using whatever theme set on context represented this.

to ensure consistency between alert dialog's decor , contents, should create contents using alert dialog's themed context.

alertdialog.builder dialogbuilder = new alertdialog.builder(this, ...)     .settitle(r.string.mirror_title)     .setpositivebutton(...)     .setnegativebutton(...);  context dialogcontext = dialogbuilder.getcontext(); edittext url = new edittext(dialogcontext);  dialogbuilder.setview(url).show(); 

as side note, looks may need specify activity theme in androidmanifest.xml , check targetsdkversion specified correctly. shouldn't seeing gingerbread-styled widgets unless explicitly targeting gingerbread themes (ex. theme or theme.light).


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

gradle error "Cannot convert the provided notation to a File or URI" -

python - NameError: name 'subprocess' is not defined -