2014-04-02 54 views
0

我想在我的操作欄中使用微調器作爲圖標。我可以把它成功。Android,如何防止微調項目選擇時顯示項目名稱?

我擴展了微調控件類併爲其分配了背景。 問題是,當我啓動應用程序,第一項,如果列表顯示在我的形象,我不想要!

第二個問題是,當用戶點擊一個項目時,它的名字將顯示在圖片的頂部,以及我不喜歡它。

換句話說,我不希望文字在我的圖像上。

這是我的課:

public class ActionSpinner extends Spinner { 

    public ActionSpinner(Context context) { 
     super(context); 
     init(); 
    } 

    public ActionSpinner(Context context, int mode) { 
     super(context, mode); 
     init(); 
    } 

    public ActionSpinner(Context context, AttributeSet attrs) { 
     super(context, attrs); 
     init(); 
    } 

    public ActionSpinner(Context context, AttributeSet attrs, int defStyle) { 
     super(context, attrs, defStyle); 
     init(); 
    } 

    public ActionSpinner(Context context, AttributeSet attrs, int defStyle, int mode) { 
     super(context, attrs, defStyle, mode); 
     init(); 
    } 

    @TargetApi(Build.VERSION_CODES.JELLY_BEAN) 
    private void init(){ 
     if(Device.getDeviceApiLevel() < Build.VERSION_CODES.JELLY_BEAN) 
      setBackgroundDrawable(getResources().getDrawable(R.drawable.ic_filter)); 
     else 
      setBackground(getResources().getDrawable(R.drawable.ic_filter)); 
    } 

} 

回答

0

我發現我的答案here

解決方案是創建自定義適配器並覆蓋textView。請看他的代碼。