-1

嗨,我的活动有错误,我不知道为什么第 6 行会显示错误

   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:padding="24dp"
    android:text="@string/question_text"
     />
<LinearLayout 
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" 
    <Button 
        android:id="@+id/true_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/true_button"
        />
    <Button 
        android:id="@+id/false_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/false_button"
        />

    </LinearLayout>

</LinearLayout>

这是我的strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="app_name">GeoQuiz</string>
<string name="question_text">Constantinople is the largest city in turkey</string>
<string name="true_button">True</string>
<string name="false_button">False</string>
<string name="action_settings">Settings</string>
</resources>'

这是我的另一个自动生成的 xml 文件

<menu xmlns:android="http://schemas.android.com/apk/res/android" >

    <item
        android:id="@+id/action_settings"
        android:orderInCategory="100"
        android:showAsAction="never"
        android:title="@string/action_settings"/>

</menu>

此文件在第 5 行显示错误,显示错误:错误:未找到与给定名称匹配的资源(在“标题”处,值为“@string/action_settings”)。

那我该如何解决这个谢谢

4

3 回答 3

1

你没有用 > 关闭你的线性布局标签。所以它找不到第一个标签的结尾。

于 2013-05-19T05:07:23.543 回答
1

在此处查看此答案:https ://stackoverflow.com/a/16631008/1306419 。尝试从那里提取有用的信息。

尝试类似:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical">
...
...
</LinearLayout>

注意:当我开始<LinearLayout标签时,我>在它的末尾使用。希望能帮助到你。

于 2013-05-19T05:09:24.700 回答
0

我想你没有得到我的第一个答案。试试这个:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="24dp"
        android:text="@string/question_text"
        />
    <LinearLayout 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:orientation="horizontal" >
        <Button 
            android:id="@+id/true_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/true_button"
        />
        <Button 
            android:id="@+id/false_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/false_button"
        />
    </LinearLayout>
</LinearLayout>
于 2013-05-19T05:12:56.643 回答