2017-03-09 120 views
0

就像我說的。我不知道如何將我的spinner中的所有內容都設置爲白色。 問題是這樣的圖像 ​​當我將所有東西都改爲白色時,我的微調器仍然是黑色的,爲什麼>

就像你看,我有白色和黑色總是與黑色的背景這個按鈕是不好可見英寸

下面是一些代碼:

<Spinner 
     android:id="@+id/spinner_money" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:layout_marginTop="10dp" 
     android:text="50$" 
     android:textColor="@color/white" 
     android:textSize="20sp" /> 

什麼是錯的傢伙?

在這裏,我confgure微調

private void configureSpinnerDataAndLogic() { 
    String[] arraySpinner = new String[]{ 
      "50", "100", "150", "200", "250", "300", "400", "500"}; 

    ArrayAdapter<String> adapter = new ArrayAdapter<>(getContext(), 
      android.R.layout.simple_list_item_1, arraySpinner); 
    spinnerData.setAdapter(adapter); 
    spinnerData.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { 
     @Override 
     public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { 
      ((TextView) parent.getChildAt(0)).setTextColor(Color.WHITE); 
      String text = spinnerData.getSelectedItem().toString(); 
      int temp = Integer.parseInt(text); 
      text_profit.setText((temp * 2) + " $ " + "100%"); 
     } 

     @Override 
     public void onNothingSelected(AdapterView<?> parent) { 
     } 
    }); 
} 

編輯:

<?xml version="1.0" encoding="utf-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item 
     android:width="20dp" 
     android:gravity="right" 
     android:layout_centerVertical="true" 
     android:height="20dp"> 
     <rotate 
      android:fromDegrees="45" 
      android:pivotX="135%" 
      android:pivotY="15%" 
      android:toDegrees="45"> 
      <shape android:shape="rectangle"> 
       <solid 
        android:color="@color/white" /> 
      </shape> 
     </rotate> 
    </item> 
</layer-list> 

enter image description here

+0

你必須設置微調 – Ibrahim

+0

與此微調yahahha這麼多工作一個自定義適配器:d – Genehme

+0

我修改了主哨 – Genehme

回答

0

您可以在XML中的紡織背景色是這樣的:

android:background="@color/white" 

,如果你正在使用下拉那麼在這樣的XML:

android:popupBackground="@color/your_color_for_items" 

在情況下,如果你正在使用自定義適配器,請檢查該thread

+0

沒有幫助:((( – Genehme

+0

@Genehme:我已經更新了我的答案,您需要對自定義適配器進行更改,請檢查它。 – Rohit

相關問題