2014-04-02 50 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。请看他的代码。