2012-10-18 97 views
0

如何更改微調標題欄樣式。更改微調標題欄樣式

enter image description here

我想更改以下項目的標題欄:

icon 
title textsize,textColor and 
background color 

我怎麼能這樣做呢?

請幫我...我已搜查谷歌和更sites.am沒有得到任何解決方案this.so請讓我知道它的possible.if可能的手段如何開發這個????請給我解釋一下。

編輯:

這是我的代碼:

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, 
      R.layout.row, R.id.country, list); 
    spinner.setPrompt("Choose a Status"); 
    // spinner.setTextColor("#FF0000"); 
    spinner.setAdapter(adapter); 
    adapter.notifyDataSetChanged(); 
    spinner.setOnItemSelectedListener(new MyOnItemSelectedListener()); 

} 
+0

你可以添加你的源代碼在這裏,以便我們可以幫助ü –

+0

@S Varun的請閱讀我更新的問題,並給這個新興的解決方案。 – user1676640

+0

嘗試蘇拉傑巴賈吉回答它可能爲你工作 –

回答

2

使用Java(代碼):

spinner.setPrompt("Title")

OR

從XML:

android:prompt="@string/spinner_title

See this to change style

+0

標題是ok.how是改變標題文字顏色,標題文字大小和標題背景顏色 – user1676640

+0

是。我看到你的代碼更新。你已經這樣做了。讓我再看一遍。 –

+1

這給一試:http://stackoverflow.com/a/12914526/1581147 我不知道,但。 –

2

你必須創建CustomSpinner,

這樣做嘗試這種方式如下,它很適合我

第1步:創建自定義微調器類

class CustomSpinnerAdapter extends CursorAdapter { 
     LayoutInflater mInflater; 

     private int cocktailname; 

     CustomSpinnerAdapter(Context context, Cursor cursor) 
     { 
      super(context, cursor); 
      mInflater = (LayoutInflater) context 
        .getSystemService(Context.LAYOUT_INFLATER_SERVICE); 

      cocktailname = cursor.getColumnIndex(YourDatabase.CK_NAME); 

     } 

     @Override 
     public View newDropDownView (Context context, Cursor cursor, ViewGroup parent) 
     { 
      return mInflater.inflate(R.layout.dropdownspinnertext, parent, false); 
     } 
     @Override 
     public View newView(Context context, Cursor cursor, ViewGroup parent) 
     { 
      return mInflater.inflate(R.layout.spinnertext, parent, false); 
     } 

     @Override 
     public void bindView(View row, Context context, Cursor cursor) 
     { 
        //Setting the Value here 
      TextView paymentname = (TextView) row.findViewById(R.id.text1);  
      paymentname.setTypeface(textFont); 
      String cocktail = cursor.getString(cocktailname); 
      paymentname.setText(cocktail); 

     } 

    } 

第2步:調用此適配器

CustomSpinnerAdapter custom_spinneradapter = new CustomSpinnerAdapter(this,youcursor); 
    spnListCocktails.setAdapter(custom_spinneradapter); 
    spnListCocktails.setOnItemSelectedListener(this); 

XML對於dropdownspinnertext

我使用經過下拉微調

<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/text1" 
style="?android:attr/spinnerDropDownItemStyle" 
android:singleLine="true" 
android:layout_width="fill_parent" 
android:layout_height="?android:attr/listPreferredItemHeight" 
android:textColor="#FFFFFF" 
android:textSize="18sp" 
android:background="@drawable/background_image" 
/> 

對於spinnertext.xml

<?xml version="1.0" encoding="utf-8"?> 
<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/text1" 
style="?android:attr/spinnerItemStyle" 
android:singleLine="true" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:textColor="#FFFFFF" 
android:gravity="center" 
android:padding="4dip" 
android:layout_marginLeft="10dip" 
android:textSize="20sp"/> 

希望它可以幫助