android - Do we need to specific its UI components (Spinner, EditText) colors explicitly when using AppCompat -


previously, have dialogfragment, doesn't specific ui components (spinner, edittext) colors explicitly.

dialog_fragment_layout.xml

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:paddingtop="10dp"     android:paddingbottom="10dp"            android:paddingleft="10dp"      android:paddingright="10dp"     android:orientation="vertical" >      <spinner         android:id="@+id/country_spinner"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:minwidth="200dp"         android:layout_marginbottom="10dp" />       <edittext         android:id="@+id/name_edit_text"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:inputtype="textnosuggestions|textcapwords"         android:maxlength="50"         android:ems="10" >          <requestfocus />     </edittext>  </linearlayout> 

i'm using

  • sherlockactionbar
  • theme.sherlock.light.darkactionbar
  • android:minsdkversion="10", android:targetsdkversion="21"

it looks following

enter image description here

after migrating to

  • appcompat
  • theme.appcompat.light.darkactionbar
  • android:minsdkversion="10", android:targetsdkversion="22"

it looks following

enter image description here

i wondering, doing wrong during migration process? there need, specific color dialogfragment ui components (spinner, edittext) colors explicitly?

is there way, make dialogfragment looks good, without having manually assigning colors spinner, edittext, ... (we let system decide best color spinner, edittext, ...) when use sherlockactionbar?

note, don't specific theme in activity or dialogfragment. specific theme in application, , expect activity or dialogfragment inherit application's.

<application     android:theme="@style/..." > 

the code dialogfragment is

source code dialogfragment

public class mydialogfragment extends android.support.v4.app.dialogfragment {      public static mydialogfragment newinstance() {         return new mydialogfragment();     }      @override     public dialog oncreatedialog(bundle savedinstancestate) {         // layout inflater         layoutinflater inflater = getactivity().getlayoutinflater();         view view = inflater.inflate(r.layout.dialog_fragment_layout, null);          final spinner countryspinner = (spinner)view.findviewbyid(r.id.country_spinner);         final edittext nameedittext = (edittext)view.findviewbyid(r.id.name_edit_text);         final countryarrayadapter countryarrayadapter = new countryarrayadapter(this.getactivity());         countryspinner.setadapter(countryarrayadapter);         nameedittext.sethint(r.string.new_watchlist_hint);         nameedittext.settext(org.yccheok.jstock.watchlist.utils.getdefaultwatchlistname());         utils.placecursoratendoftext(nameedittext);          final alertdialog dialog = new alertdialog.builder(this.getactivity())         .settitle(r.string.new_watchlist_title)         .setview(view)         // add action buttons         .setpositivebutton(android.r.string.ok, new dialoginterface.onclicklistener() {             @override             public void onclick(dialoginterface dialog, int id) {             }         })         .setnegativebutton(android.r.string.cancel, new dialoginterface.onclicklistener() {             public void onclick(dialoginterface dialog, int id) {             }         })                    .create();          dialog.setcanceledontouchoutside(true);          // http://stackoverflow.com/questions/2620444/how-to-prevent-a-dialog-from-closing-when-a-button-is-clicked         dialog.setonshowlistener(new dialoginterface.onshowlistener() {              @override             public void onshow(dialoginterface dialoginterface) {                  button b = dialog.getbutton(alertdialog.button_positive);                 b.setonclicklistener(new view.onclicklistener() {                      @override                     public void onclick(view view) {                         ...                     }                 });             }         });                      return dialog;     } 

code show dialogfragment

private void showmydialogfragment() {             fragmentmanager fm = this.getactivity().getsupportfragmentmanager();     mydialogfragment mydialogfragment = mydialogfragment.newinstance();     mydialogfragment.settargetfragment(this, 0);     mydialogfragment.show(fm, my_dialog_fragment);         } 

the support library version of alertdialog, support.v7.app.alertdialog, added in android support library 22.1, brings single material style dialog (and theming views within) api7+ devices. if using appcompat, should using support library alertdialog.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -