始终显示“x选中”的微调器

时间:2013-09-22 16:41:57

标签: android-actionbar spinner selection

我现在已经花了几个小时来获得如下图所示的选择微调器。 如何实现这一目标,以获得始终显示“x selected”而不是当前选择的微调器。

感谢您的帮助。

Android Developer Design ActionBar

1 个答案:

答案 0 :(得分:0)

好的,我终于成功了。

我编写自己的Adapter,它会覆盖getView(...) - Method并返回TextView。

public class SelectionSpinnerAdapter extends ArrayAdapter<CharSequence>{

    Context context;

    public SelectionSpinnerAdapter(Context context, int resource, CharSequence[] objects) {
        super(context, resource, objects);
        this.context = context;
    }

    @Override
    public View getView (int position, View convertView, ViewGroup parent) {
        TextView textView = new TextView(context, null, android.R.layout.simple_spinner_item);
        textView.setText("Your Text");
        return textView;
    }

}