Android自定义导航抽屉

时间:2015-04-13 17:45:40

标签: android xml android-layout

如何像附加图像一样创建导航抽屉。我已经完成了android的默认导航抽屉。 enter image description here

1 个答案:

答案 0 :(得分:0)

您可以使用自定义Adapter作为导航栏:

mDrawerList = (ListView) findViewById(R.id.left_drawer);
mDrawerList.setAdapter(new DrawerAdapter(this, R.layout.yourcustomlayout, items));

使用getView方法定义自定义适配器:

public class DrawerAdapter extends ArrayAdapter<?> {
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // customize your list item here
        // add icon for example
    }
}

应在自定义布局中设置背景和文字颜色。

更多信息here