java - Can't manage to change text color on Spinner -
i've tried lot of other answers on so, none of them seem work me. i'm not sure did wrong.
here's xml:
<spinner android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/product_category_spinner" android:theme="@style/appartmentblue" />
and here's java (it's dialogfragment extending class):
@override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { // inflate layout fragment view v = inflater.inflate(r.layout.fragment_product_dialog, container, false); spinner productcategory = (spinner) v.findviewbyid(r.id.product_category_spinner); arrayadapter<string> spinneradapter = new arrayadapter<string>(getactivity().getapplicationcontext(), android.r.layout.simple_spinner_dropdown_item, getresources().getstringarray(r.array.category_array)); spinneradapter.setdropdownviewresource(android.r.layout.simple_spinner_dropdown_item); productcategory.setadapter(spinneradapter); // setcancelable(false); homecoming v; }
the thing is, text white on bright gray. came way default, if came in black foreground wouldn't need touch it. why's doing this? theme extends theme.holo.light.darkactionbar
.
i don't wanna set @ runtime, i'm gonna have lot of spinners , want global across app, alternative me add together later themes.
i hope helps:
my spinner:
<spinner android:id="@+id/spinner_cat" android:paddingleft="0dp" android:paddingright="0dp" android:paddingbottom="0dp" android:paddingtop="0dp" android:layout_marginstart="@dimen/left_margin_large" android:layout_marginleft="@dimen/left_margin_large" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centervertical="true"/>
setting adapters:
private final int _singleitemres = r.layout.simple_spinner_item; private final int _dropdownres = r.layout.simple_spinner_dropdown_item; arrayadapter<string> adapter = new arrayadapter<string>(_handler.getcontext(), _singleitemres, gettitles()); adapter.setdropdownviewresource(_dropdownres);
simple_spinner_item.xml:
<textview xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/text1" android:layout_width="match_parent" android:layout_height="wrap_content" android:singleline="true" android:textcolor="@color/actionbar_text" android:textsize="20sp" android:textstyle="normal"/>
simple_spinner_dropdown_item.xml:
<textview xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/text1" style="?android:attr/spinnerdropdownitemstyle" android:layout_width="match_parent" android:layout_height="48dp" android:background="@color/primary_dark" android:ellipsize="marquee" android:layout_centervertical="true" android:singleline="true" android:paddingright="@dimen/left_margin_small" android:paddingleft="@dimen/left_margin_small" android:textcolor="@color/actionbar_text"/>
let me know if missing reply , add together in.
java android android-spinner android-styles
No comments:
Post a Comment