当前位置: 首页 > 知识库问答 >
问题:

Generate Signed APK时:错误:(131)错误:需要类型为styleable[ResourceType]的资源

龙高歌
2023-03-14

/*//UserProfile NavDraweritems.add(new NavDrawerItem(NavMenutitles[1],NavMenuicons.getResourceId(1,-1)));*///Payment NavDraweritems.add(new NavDrawerItem(NavMenutitles[1],NavMenuicons.getResourceId(1,-1)))中出现错误occure;//邀请好友navdraweritems.add(新建NavDrawerItem(navmenutitles[2],navmenuicons.getResourceId(2,-1)));//帮助navdraweritems.add(新建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)));

以下是我的完整代码:@override public View onCreateView(LayoutInflater,ViewGroup container,Bundle savedInstanceState){View 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)));

/*//用户配置文件navdraweritems.add(新建NavDrawerItem(NavMenutitles[1],navMenuicons.getResourceID(1,-1)));*///付款navdraweritems.add(新建NavDrawerItem(NavMenutitles[1],navMenuicons.getResourceID(1,-1)));//邀请好友navdraweritems.add(新建NavDrawerItem(navmenutitles[2],navmenuicons.getResourceId(2,-1)));//帮助navdraweritems.add(新建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;
}

共有1个答案

孙夕
2023-03-14

试试这个(为我工作)

  • 将此行添加到您的build.gradle文件

android{

  lintOptions {
     disable "ResourceType"} 

}

 类似资料: