Sherlock导航抽屉带头

时间:2015-06-29 21:26:17

标签: android actionbarsherlock navigation-drawer

我有一个Sherlock Actionbar的应用程序。它有一个带有很多标题的导航抽屉,如下图所示:

Picture 1

我想通过制作收藏夹部分来更轻松地找到最常用的标题。为了实现这一点,我必须在导航抽屉中添加两个标题和一个按钮。就像这张照片一样:

enter image description here

我可以用一些帮助来做到这一点。你能告诉我怎么做吗? 我的java代码:

public class MenuListAdapter extends BaseAdapter {

// Declare Variables
Context context;
String[] mTitle;
String[] mSubTitle;
LayoutInflater inflater;

public MenuListAdapter(Context context, String[] title, String[] subtitle)
        {
    this.context = context;
    this.mTitle = title;
    this.mSubTitle = subtitle;
}

@Override
public int getCount() {
    return mTitle.length;
}

@Override
public Object getItem(int position) {
    return mTitle[position];
}

@Override
public long getItemId(int position) {
    return position;
}

@SuppressLint("ViewHolder") public View getView(int position, View convertView, ViewGroup parent) {
    // Declare Variables
    TextView txtTitle;
    TextView txtSubTitle;

    inflater = (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View itemView = inflater.inflate(R.layout.drawer_list_item, parent,
            false);

    // Locate the TextViews in drawer_list_item.xml
    txtTitle = (TextView) itemView.findViewById(R.id.title);
    txtSubTitle = (TextView) itemView.findViewById(R.id.subtitle);

    // Set the results into TextViews
    String[] title = context.getResources().getStringArray(R.array.title);
    String[] subtitle = context.getResources().getStringArray(R.array.subtitle);
    txtTitle.setText(title[position]);
    txtSubTitle.setText(subtitle[position]);

    return itemView;
}

}

0 个答案:

没有答案