android - Action Bar dropdown open and closed item styles -
i'm trying style action bar list navigation such has white text in closed state. when i've done that, though, has turned all text white, doesn't work white dropdown.
is there way style each individually? docs non-existant :(
add custom layout adapter
. in have created 1 layout inside have add 1 textview
. text color
, background color
.
and set atapter like:
arrayadapter<string> adapter = new arrayadapter<string>( getbasecontext(), r.layout.my_spinner_style, r.id.textview1, countries);
here
r.layout.my_spinner_style
custom layout.
r.id.textview1
textview id my_spinner_style.xml
.
you can applay awn style inside textview. check this , this aretical.
check code:
inside oncreate
:
/** create array adapter populate dropdownlist */ arrayadapter<string> adapter = new arrayadapter<string>( getbasecontext(), r.layout.my_spinner_style, r.id.textview1, countries); /** enabling dropdown list navigation action bar */ getactionbar().setnavigationmode(actionbar.navigation_mode_list); /** defining navigation listener */ actionbar.onnavigationlistener navigationlistener = new onnavigationlistener() { @override public boolean onnavigationitemselected(int itemposition, long itemid) { toast.maketext(getbasecontext(), "you selected : " + countries[itemposition], toast.length_short).show(); return false; } }; /** * setting dropdown items , item navigation listener actionbar */ getactionbar().setlistnavigationcallbacks(adapter, navigationlistener);
my_spinner_style.xml
<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="#ffff00" > <textview android:id="@+id/textview1" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="large text" android:textappearance="?android:attr/textappearancelarge" /> </linearlayout>
Comments
Post a Comment