当尝试运行 Android Activity 时,我收到此错误: 错误:(8, 17) 资源 ID 不能为空字符串(在“id”处,值为“@+id/”)。 这似乎只是最后一个 Activity 的错误。每次我尝试运行该程序时,都会在 Activity 末尾添加一行:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainMenu">
成为
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.example.kirky_000.madmath.Multiplication"
android:id="@+id/">
错误仅与“android:id="@+id/">”有关。
最佳答案
给relativeLayout一个id,不要留空。它可以是你想要的任何东西。例如: android:id="@+id/myRelativeLayout"
。你的RelativeLayout看起来像这样
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.example.kirky_000.madmath.Multiplication"
android:id="@+id/myRelativeLayout">
关于android - 资源 ID 不能为空字符串(位于 'id' ,值为 '@+id/"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30363774/