作者henry4343 (henry)
看板AndroidDev
標題[問題] 更改getActionBar上spinner的文字顏色?
時間Thu Nov 8 17:26:39 2012
請問一下各位~
因為我使用了getActionBar上面的spinner進行某些功能
getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
ArrayAdapter<String> adapterPlace = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_dropdown_item, String[]);
getActionBar().setListNavigationCallbacks(adapterPlace, actionBarListener);
可是因為actionBar 和 spinner的字顏色都是黑的
讓我非常的困擾
google了很多spinner相關的文章不過都好複雜看不太懂
我只要想要把spinner顯示的文字和拉下來可以選擇的文字都改成白色的就好
目前看到最簡單使用的是使用下面的adapter
static class CustomArrayAdapter<T> extends ArrayAdapter<T>
{
public CustomArrayAdapter(Context ctx, T [] objects)
{
super(ctx, android.R.layout.simple_spinner_item, objects);
}
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent)
{
View view = super.getView(position, convertView, parent);
TextView text = (TextView)view.findViewById(android.R.id.text1);
text.setTextColor(Color.RED);
return view;
}
}
不過此adapter可以改變選項裡面的文字顏色
但是卻不能改變顯在是actionBar上面的顏色
希望有經驗的大大可以幫幫我
感謝~
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 124.11.137.186
2F:→ bukiya:item name不知道的話,可以參考sdk資料夾下 /res/values/ 11/08 19:14
3F:→ bukiya:themes.xml和styles.xml兩個檔案裡的寫法 11/08 19:14
4F:→ dreamcwli:你是不是用了 Theme.Holo.Light.DarkActionBar? 11/09 11:34
5F:→ dreamcwli:是的話把 ArrayAdapter 的 constructor 那邊的 this 改 11/09 11:36
6F:→ dreamcwli:成 getActionBar().getThemedContext() 11/09 11:36
7F:→ henry4343:感謝樓上!!!! 11/13 10:24