Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/222.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android自定义导航抽屉_Android_Xml_Android Layout - Fatal编程技术网

Android自定义导航抽屉

Android自定义导航抽屉,android,xml,android-layout,Android,Xml,Android Layout,如何创建像附加图像一样的导航抽屉。我已经完成了android的默认导航抽屉 您可以为导航抽屉使用自定义的适配器: mDrawerList = (ListView) findViewById(R.id.left_drawer); mDrawerList.setAdapter(new DrawerAdapter(this, R.layout.yourcustomlayout, items)); 并使用getView方法定义自定义适配器: public class DrawerAdapter ext

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

您可以为导航抽屉使用自定义的
适配器

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
    }
}
public类DrawerAdapter扩展了ArrayAdapter{
@凌驾
公共视图getView(int位置、视图转换视图、视图组父视图){
//在此处自定义您的列表项
//例如添加图标
}
}
背景和文本颜色应在自定义布局中设置

更多信息