此错误发生 /* // 用户资料 navDrawerItems.add(new NavDrawerItem(navMenuTitles [1],navMenuIcons.getResourceId(1,-1))); * / //付款 navDrawerItems.add(new NavDrawerItem(navMenuTitles [1],navMenuIcons.getResourceId(1,-1))); // 邀请朋友 navDrawerItems.add(new NavDrawerItem(navMenuTitles [2],navMenuIcons.getResourceId(2,-1))); // 救命 navDrawerItems.add(new NavDrawerItem(navMenuTitles [3],navMenuIcons.getResourceId(3,-1)));
//Trip History
navDrawerItems.add(new NavDrawerItem(navMenuTitles[4], navMenuIcons.getResourceId(4, -1)));
navDrawerItems.add(new NavDrawerItem(navMenuTitles[5], navMenuIcons.getResourceId(5, -1)));
navDrawerItems.add(new NavDrawerItem(navMenuTitles[6], navMenuIcons.getResourceId(6, -1)));
navDrawerItems.add(new NavDrawerItem(navMenuTitles[7], navMenuIcons.getResourceId(7, -1)));
navDrawerItems.add(new NavDrawerItem(navMenuTitles[8], navMenuIcons.getResourceId(8, -1)));
这是我的代码完成: @覆盖 public View onCreateView(LayoutInflater inflater,ViewGroup容器, Bundle savedInstanceState){ 查看rootView = inflater.inflate(R.layout.fragment_navigation_drawer,container,false); mDrawerListView =(ListView)rootView.findViewById(R.id.listViewDrawer); mToolbar =((NavigationActivity)getActivity())。getToolbar();
/* mDrawerListView = (ListView) inflater.inflate(
R.layout.fragment_navigation_drawer, container, false);*/
// load slide menu items
String[] navMenuTitles = getResources().getStringArray(R.array.nav_drawer_items);
// nav drawer icons from resources
TypedArray navMenuIcons = getResources().obtainTypedArray(R.array.nav_drawer_icons);
mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);
ArrayList<NavDrawerItem> navDrawerItems = new ArrayList<NavDrawerItem>();
// adding nav drawer items to array
// Home
navDrawerItems.add(new NavDrawerItem(navMenuTitles[0], navMenuIcons.getResourceId(0, -1)));
/ * // UserProfile navDrawerItems.add(new NavDrawerItem(navMenuTitles [1],navMenuIcons.getResourceId(1,-1))); * / //付款 navDrawerItems.add(new NavDrawerItem(navMenuTitles [1],navMenuIcons.getResourceId(1,-1))); // 邀请朋友 navDrawerItems.add(new NavDrawerItem(navMenuTitles [2],navMenuIcons.getResourceId(2,-1))); // 救命 navDrawerItems.add(new NavDrawerItem(navMenuTitles [3],navMenuIcons.getResourceId(3,-1)));
//Trip History
navDrawerItems.add(new NavDrawerItem(navMenuTitles[4], navMenuIcons.getResourceId(4, -1)));
navDrawerItems.add(new NavDrawerItem(navMenuTitles[5], navMenuIcons.getResourceId(5, -1)));
navDrawerItems.add(new NavDrawerItem(navMenuTitles[6], navMenuIcons.getResourceId(6, -1)));
navDrawerItems.add(new NavDrawerItem(navMenuTitles[7], navMenuIcons.getResourceId(7, -1)));
navDrawerItems.add(new NavDrawerItem(navMenuTitles[8], navMenuIcons.getResourceId(8, -1)));
//开启/关闭驱动程序模式
// Recycle the typed array
navMenuIcons.recycle();
// setting the nav drawer list adapter
adapter = new NavDrawerListAdapter(getActivity(),
navDrawerItems);
mDrawerListView.setAdapter(adapter);
mDrawerListView
.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
selectItem(position);
adapter.setSelectedItem(position);
}
});
// Select either the default item (0) or the last selected item.
selectItem(mCurrentSelectedPosition);
adapter.setSelectedItem(mCurrentSelectedPosition);
return rootView;
}
答案 0 :(得分:0)
试试这个(为我工作)
android {
lintOptions { disable "ResourceType"}
}