Java 无法解析或不是字段

Java 无法解析或不是字段,java,android,button,Java,Android,Button,我想创建一个应用程序,它将记录应用程序的所有通知。我正在创建按钮,但我得到“无法解析或不是字段” 这是活动_get_notification.xml <Button android:id="@+id/OKButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" a

我想创建一个应用程序,它将记录应用程序的所有通知。我正在创建按钮,但我得到“无法解析或不是字段”

这是活动_get_notification.xml

   <Button
    android:id="@+id/OKButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="116dp"
    android:text="@string/ok" />
而我的androidmanifest是

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.notificationnotifier"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="16"
        android:targetSdkVersion="16" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.notificationnotifier.GetNotification"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.example.notificationnotifier.monitorNotification"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.DEFAULT" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>
如日志所示:

未找到与给定名称(在“text”处)匹配的资源 “@string/ok”)

表示您忘记在
res/values/strings.xml
文件中添加
ok
菜单设置
字符串。将其添加为:

<resources>
    <string name="ok">ok button</string>
    <string name="menu_settings">menu settings</string>
</resources>

ok按钮
菜单设置

您从何处得到该错误?请提供完整的日志CatNew Intent(“com.example.notificationnotifier”);是您的包,而不是活动确保您在此处为活动设置了正确的布局
setContentView(R.layout.Activity\u get\u通知)
或您在
活动\u获取\u通知
版面中有一个带有
ok按钮
id的按钮?您的版面未编译,因为您的strings.xml有问题。请发布版面的全部内容和字符串的全部内容。添加菜单设置解决了问题。我只是想知道为什么它总是把责任推到总统身上。无论如何,谢谢你!!!:D@srhsnl:最欢迎的朋友。你这些刺可能有什么关系吗
[2013-02-04 01:18:52 - NotificationNotifier] W/ResourceType( 7432): Bad XML block: header size 60 or total size 0 is larger than data size 0
[2013-02-04 01:18:52 - NotificationNotifier] C:\Users\Trend\workspace\NotificationNotifier\res\layout\activity_get_notification.xml:7: error: Error: No resource found that matches the given name (at 'text' with value '@string/ok').
[2013-02-04 01:18:52 - NotificationNotifier] C:\Users\Trend\workspace\NotificationNotifier\res\menu\activity_get_notification.xml:3: error: Error: No resource found that matches the given name (at 'title' with value '@string/menu_settings').
[2013-02-04 01:20:23 - NotificationNotifier] W/ResourceType( 6764): Bad XML block: header size 85 or total size 0 is larger than data size 0
[2013-02-04 01:20:23 - NotificationNotifier] C:\Users\Trend\workspace\NotificationNotifier\res\layout\activity_get_notification.xml:7: error: Error: No resource found that matches the given name (at 'text' with value '@string/ok').
[2013-02-04 01:20:23 - NotificationNotifier] C:\Users\Trend\workspace\NotificationNotifier\res\menu\activity_get_notification.xml:3: error: Error: No resource found that matches the given name (at 'title' with value '@string/menu_settings').
[2013-02-04 01:24:18 - NotificationNotifier] W/ResourceType( 5092): Bad XML block: header size 147 or total size 0 is larger than data size 0
[2013-02-04 01:24:18 - NotificationNotifier] C:\Users\Trend\workspace\NotificationNotifier\res\layout\activity_get_notification.xml:7: error: Error: No resource found that matches the given name (at 'text' with value '@string/ok').
[2013-02-04 01:24:18 - NotificationNotifier] C:\Users\Trend\workspace\NotificationNotifier\res\menu\activity_get_notification.xml:3: error: Error: No resource found that matches the given name (at 'title' with value '@string/menu_settings').
<resources>
    <string name="ok">ok button</string>
    <string name="menu_settings">menu settings</string>
</resources>