Android actionbar spinner selected item, subtitle and dropdown list

后端 未结 2 1754
别跟我提以往
别跟我提以往 2021-01-31 11:29

How can I make spinner in action bar to have different item as selected (shown in the action bar top) then the one in the drop down list? Example is google mail with spinner in

2条回答
  •  攒了一身酷
    2021-01-31 12:15

    To have a different view in the action bar spinner than in the spinner list, you can use a BaseAdapter or an ArrayAdapter and override some methods:

      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
        // Return a view which appears in the action bar.
    
        return yourCustomView..;
      }
    
      @Override
      public View getDropDownView(int position, View convertView, ViewGroup parent) {
        // Return a view which appears in the spinner list.
    
        // Ignoring convertView to make things simpler, considering
        // we have different types of views. If the list is long, think twice!
        return super.getView(position, null, parent);
      }
    

提交回复
热议问题