我有一个导航抽屉,我想使用代码
添加第二个标题我知道使用此代码我可以添加第一个标题
View header = View.inflate(this, R.layout.aaaaaaa, null);
mDrawerList.addHeaderView(header, null, false);
但我不明白如何添加新的第二个标题......
示例:"最近的标签"
所以我做了什么:
dataList = new ArrayList<DrawerItem>();
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
mDrawerList = (ListView) findViewById(R.id.left_drawer);
adapter = new CustomDrawerAdapter(this, R.layout.aaaaaaaaaaaaaa,
dataList);
View header = View.inflate(this, R.layout.header, null);
mDrawerList.addHeaderView(header, null, false);
mDrawerList.setAdapter(adapter);// Then I cannot add second title
dataList.add(new DrawerItem("One ",R.drawable.aa));
dataList.add(new DrawerItem("Two",R.drawable.aa));
//How to add new title????
答案 0 :(得分:0)
通过定义自定义适配器,这只是一个分段列表视图。从ListView Tips & Tricks #2: Sectioning Your ListView
学习和实施