如何添加微调,以副标题 - 在播放音乐应用程序为Android? [英] How to add spinner to subtitle - as in the Play Music app for Android?

查看:137
本文介绍了如何添加微调,以副标题 - 在播放音乐应用程序为Android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参阅附件图像。

setListNavigationCallbacks(mSpinnerAdapter,mNavigationCallback)补充道下的我的媒体库的转动旋转器,我不能在它添加一个子表。我无法找到它增加了一个微调的方法的所有音乐的,而不是搞乱与操作栏的主标题。

setListNavigationCallbacks(mSpinnerAdapter, mNavigationCallback) adds a spinner pivoted under "My Library", and I cannot add a sub-list under it. I am unable to find a method which adds a spinner for "ALL MUSIC", not messing up with the main title of the action bar.

任何帮助是AP preciated!

Any help is appreciated !

推荐答案

它看起来像一个定制 ArrayAdapter 你需要实现 getDropDownView 键,返回你希望看到的视图。

It appears like a customised ArrayAdapter You need to implement getDropDownView and return the view that you would like to see.

随意修改code。这是概念只是一个证明。 在您的活动:

Feel free to modify the code. This is just a proof of concept. In your activity:

getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    getActionBar().setTitle("");

    getActionBar().setListNavigationCallbacks(new MySpinnerAdapter(this, R.layout.customspinneritem, items), new OnNavigationListener() {

        @Override
        public boolean onNavigationItemSelected(int itemPosition, long itemId) {

            return false;
        }
    });

MySpinnerAdapter:

MySpinnerAdapter:

 public class MySpinnerAdapter extends ArrayAdapter<String>{

// CUSTOM SPINNER ADAPTER
private Context mContext;
public MySpinnerAdapter(Context context, int textViewResourceId,
        String[] objects) {
    super(context, textViewResourceId, objects);

    mContext = context;
    // TODO Auto-generated constructor stub
}

@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub
    return getCustomView(position, convertView, parent);
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub
    return getCustomView(position, convertView, parent);
}

public View getCustomView(int position, View convertView,ViewGroup parent) {
// TODO Auto-generated method stub
// return super.getView(position, convertView, parent);


LayoutInflater inflater =  
    ( LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);


ViewHolder holder;
if (convertView == null) {
convertView = inflater.inflate(R.layout.customspinneritem, null);
holder = new ViewHolder();
holder.txt01 = (TextView) convertView.findViewById(R.id.TextView01);
holder.txt02 = (TextView) convertView.findViewById(R.id.TextView02);

convertView.setTag(holder);

} else {

holder = (ViewHolder) convertView.getTag();
}

holder.txt01.setText("My Library");
holder.txt02.setText("ALL MUSIC");

return convertView;
}

class ViewHolder {
    TextView txt01;
    TextView txt02;
}



} // end custom adapter

这篇关于如何添加微调,以副标题 - 在播放音乐应用程序为Android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆