Text color of a closed spinner

前端 未结 6 1348
孤独总比滥情好
孤独总比滥情好 2020-12-01 16:03

I understand that the closed spinner is actually a View, I think. But I am guessing it has a TextView there somewhere to show the text. How do I

6条回答
  •  再見小時候
    2020-12-01 16:31

    For Change Textcolor of closed Spinner I have do in this way it works

    @Override
    public View getDropDownView(int position, View convertView, ViewGroup parent) {
      View view = convertView;
      if (view == null) {
        LayoutInflater vi = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = vi.inflate(R.layout.context_row_icon, null);
      }
      TextView mTitle = (TextView) view.findViewById(R.id.context_label);
      ImageView flag = (ImageView) view.findViewById(R.id.context_icon);                
    
      mTitle.setText(values[position].getLabel(activity));
    
      if (!((LabelItem) getItem(position)).isEnabled()) {
        mTitle.setTextColor(activity.getResources().getColor(R.color.context_item_disabled));
      } else {
        mTitle.setTextColor(activity.getResources().getColor(R.color.context_item));
      }
      return view;
    }
    
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      View view = convertView;
      if (view == null) {
        LayoutInflater vi = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = vi.inflate(R.layout.context_row_icon, null);
      }
      TextView mTitle = (TextView) view.findViewById(R.id.context_label);
      ImageView flag = (ImageView) view.findViewById(R.id.context_icon);                
    
      mTitle.setText(values[position].getLabel(activity));
      mTitle.setTextColor(activity.getResources().getColor(R.color.context_item_disabled));
      return view;
    }
    

提交回复
热议问题