How to add spinner to subtitle - as in the Play Music app for Android?

后端 未结 3 1658
谎友^
谎友^ 2020-12-13 15:53

\"Play

Please refer to the attached image.

setListNavigationCallbacks(mSpinne

3条回答
  •  情深已故
    2020-12-13 16:48

    I can't comment on answers quite yet because of my reputation, but to implement this the same way as the Google Music app I think you would want to use a different method for getDropDownView() because the dropdown on Google Music is just like a regular dropdown.

    Replacing prijupaul's method with the following is the idea for which you'd be looking.

    Like this:

    @Override
    public View getDropDownView(int position, View convertView, ViewGroup parent) {
        DropDownViewHolder holder = null;
    
        if (convertView == null) {
            LayoutInflater inflater = ((Activity) mContext).getLayoutInflater();
            convertView = inflater.inflate(R.layout.dropdown_list_item, parent, false);
    
            holder = new DropDownViewHolder();
            holder.mTitle = (TextView) convertView.findViewById(R.id.textView_dropdown_title);
    
            convertView.setTag(holder);
        } else {
            holder = (DropDownViewHolder) convertView.getTag();
        }
    
        // Should have some sort of data set to go off of, we'll assume
        // there is a some array called mData.
        holder.mTitle.setText(mData[position]);
    
        return convertView;
    }
    
    public class DropDownViewHolder {
        TextView mTitle;
    }
    

    I figured I should put the code in to be explicit.

提交回复
热议问题