Android 带ActionBarSherlock的导航抽屉部分
我有一个使用ActionBarSherlock的应用程序: 我想在导航抽屉中有一些部分,就像这张图片上一样: 标题是从字符串数组生成的。我怎样才能做到这一点?提前谢谢 我的java:Android 带ActionBarSherlock的导航抽屉部分,android,navigation-drawer,Android,Navigation Drawer,我有一个使用ActionBarSherlock的应用程序: 我想在导航抽屉中有一些部分,就像这张图片上一样: 标题是从字符串数组生成的。我怎样才能做到这一点?提前谢谢 我的java: public class MenuListAdapter extends BaseAdapter { // Declare Variables Context context; String[] mTitle; String[] mSubTitle; LayoutInflater inflater; pub
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;
}
}
哇,动作酒吧夏洛克。我建议扔掉它,因为它真的不再相关了 您可能需要在适配器中定义两个ItemType,一个用于标题,另一个用于实际可单击的项目 您需要实现两种方法。在getView()中,您可以区分需要充气的布局 另外:不要每次都充气。如果
convertView
不为空,则可以使用该选项
我建议你看看这个视频:
这对于任何android开发人员来说都是必不可少的查看功能。为什么要使用
ActionBarSherlock
?这是不推荐的。我应该使用什么来同时拥有导航抽屉和选项卡?官方Android库:AppCompat已经存在了2年(正式)。请参阅:。