错误与Android示例项目“没有发现资源标识符”标识符、示例、错误、发现

由网友(对不起丶我听腻了)分享简介:我想开了Android示例项目 - 导航抽屉在Android的工作室,但在构建它遇到错误I am trying to open the Android sample project - Navigation Drawer in Android Studio, but got error while building...

我想开了Android示例项目 - 导航抽屉在Android的工作室,但在构建它遇到错误

I am trying to open the Android sample project - Navigation Drawer in Android Studio, but got error while building it.

这些都是重现步骤吧:

从Android的工作室欢迎页面,选择导入一个Android code样品 搜索导航抽屉,选择它,然后单击下一步 指定项目的位置,然后单击完成 然后运行该项目,该摇篮构建失败,出现以下错误: 错误:(43)未找到属性的layoutManager封装com.example.android.navigationdrawer'资源标识符 From Android Studio welcome page, select Import an Android code sample Search for Navigation Drawer, select it and click 'Next' Specify project location and click 'Finish' Then run the project, the gradle build failed with the following error: Error:(43) No resource identifier found for attribute 'layoutManager' in package 'com.example.android.navigationdrawer'

Android的工作室的版本 - 1.4 Beta 4的

The version of Android Studio is - 1.4 Beta 4

在此先感谢您的帮助。

推荐答案

编译器不能找到这个属性在 activity_navigation_drawer.xml

The compiler cannot find this attribute in the activity_navigation_drawer.xml:

app:layoutManager="LinearLayoutManager"

要解决这个问题

从XML删除这个属性让你的Recyclerview看起来是这样的:

Remove this attribute from the XML so your Recyclerview looks like this:

<android.support.v7.widget.RecyclerView
android:id="@+id/left_drawer"
android:scrollbars="vertical"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="left|start"
android:choiceMode="singleChoice"
android:divider="@null"/>

preSS的摇篮同步按钮

press the Gradle Sync button

NavigationDrawerActivity ,在你的OnCreate()中添加以下两行$​​ C $ C

In NavigationDrawerActivity, add the following 2 lines of code in your OnCreate();

LinearLayoutManager mLinearLayoutmanager = new LinearLayoutManager(this);
mDrawerList.setLayoutManager(mLinearLayoutmanager);

所以,你的code现在看起来是这样的:

So your code now looks like this:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_navigation_drawer);

    mTitle = mDrawerTitle = getTitle();
    mPlanetTitles = getResources().getStringArray(R.array.planets_array);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (RecyclerView) findViewById(R.id.left_drawer);

    LinearLayoutManager mLinearLayoutmanager = new LinearLayoutManager(this);
    mDrawerList.setLayoutManager(mLinearLayoutmanager);
    ....

好运气

修改: 之所以出现这种原始的XML code是不再工作,是最有可能的是,的xmlns:程序=htt​​p://schemas.android.com/apk/res-auto命名空间不再支持的layoutManager 属性。

Edit: The reason why this the original xml code is no longer working, is most likely that the xmlns:app="http://schemas.android.com/apk/res-auto" namespace is no longer supporting the layoutManager attribute.

上的命名空间更多信息可以在这里找到:http://stackoverflow.com/a/26692768/3708094

More info on the namespace can be found here: http://stackoverflow.com/a/26692768/3708094

阅读全文

相关推荐

最新文章