2013-06-23 16 views
0

我有一個奇怪的問題,有關從我的摩托羅拉Defy 2.2中顯示從微調選擇的文本。我創建了一個有一個微調從其中用戶可以選擇一個選項的佈局,但問題是即使我從微調列表中選擇一個項目不要在box中顯示該項目。我知道默認情況下defy中的文本顏色是白色的,我的佈局背景也是白色的,這會隱藏文本,但我也指定了旋轉器的佈局中的文本顏色屬性爲黑色,它仍然不顯示text.My佈局如下所示:微調只顯示Motorola Defy 2.2上的選定文本?

<?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:orientation="vertical" > 
    <LinearLayout 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="20.0dip" 
       android:layout_marginRight="20.0dip" 
       android:layout_marginTop="7.0dip" 
       android:background="@drawable/rectangle_shape" > 

       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="fill_parent" 
        android:layout_gravity="right|center" 
        android:gravity="right|center" 
        android:paddingBottom="7.0dip" 
        android:paddingLeft="10.0dip" 
        android:paddingRight="8.0dip" 
        android:paddingTop="7.0dip" 
        android:text="Concession" 
        android:textColor="@color/white" 
        android:textSize="16.0sp" /> 

       <Spinner 
        android:id="@+id/CSpinner" 
        android:layout_width="0.0dip" 
        android:layout_height="fill_parent" 
        android:layout_weight="1.0" 
        android:background="@drawable/rectangle_shape_middle" 
        android:entries="@array/C_arrays" 
        android:paddingLeft="6.0dip" 
        android:prompt="@string/C_prompt" 
        android:textColor="@color/black" 
        android:textSize="16.0sp" /> 

       <ImageView 
        android:id="@+id/SpinnerSelector" 
        android:layout_width="wrap_content" 
        android:layout_height="fill_parent" 
        android:layout_gravity="right" 
        android:background="@drawable/rectangle_shape_end" 
        android:paddingLeft="3.0dip" 
        android:paddingRight="3.0dip" 
        android:src="@drawable/ic_navigation_expand" /> 
      </LinearLayout> 
</LinearLayout> 

的代碼上的其他手機一樣的三星Galaxy S2,S3做工精細,並注意爲well.Please幫助我。

由於提前

+0

我認爲微調不具有屬性android:textColor.Maybe我需要使用java來做到這一點。 – user818455

+0

我發現我的解決方案[這裏](http://stackoverflow.com/questions/6159113/android-where-is-the-spinner-widgets-text-color-attribute-hiding) – user818455

回答

1

我回答我的問題,因爲它可能會幫助others.The問題摩托羅拉Defy是,它有一個默認的文本顏色設置爲白色和微調,我們不能用android:textColor="@color/white",因爲他們不會work.To改變微調的文字顏色,我們需要使用下面的代碼:

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <style name="MooTheme" parent="android:Theme"> 
     <item name="android:spinnerItemStyle">@style/MooSpinnerItem</item> 
    </style> 

    <style name="MooSpinnerItem" parent="android:Widget.TextView.SpinnerItem"> 
     <item name="android:textAppearance">@style/MooTextAppearanceSpinnerItem</item> 
    </style> 

    <style name="MooTextAppearanceSpinnerItem" parent="android:TextAppearance.Widget.TextView.SpinnerItem"> 
     <item name="android:textColor">#F00</item> 
    </style> 
</resources> 

現在,我們只需要MooTheme適用於我們的應用程序,你會看到一個在旋轉的文本。

+0

謝謝' @ style/MooMooTheme'這工作對我來說.. –