Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android首选项活动-R无法解析为变量_Android_Android Preferences - Fatal编程技术网

Android首选项活动-R无法解析为变量

Android首选项活动-R无法解析为变量,android,android-preferences,Android,Android Preferences,我试图创建一个首选项活动,但出现以下错误 R cannot be resolved to a variable 设置引用.java package com.m7.nomad.preferences; import android.os.Bundle; import android.preference.PreferenceActivity; public class SettingsPreference extends PreferenceActivity { @Overri

我试图创建一个首选项活动,但出现以下错误

R cannot be resolved to a variable
设置引用.java

package com.m7.nomad.preferences;

import android.os.Bundle;
import android.preference.PreferenceActivity;

public class SettingsPreference extends PreferenceActivity  {


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.preferences_settings);
    }
}
res/xml/preferences\u settings.xml

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >

    <PreferenceScreen
        android:key="settingsPrefScreen"
        android:title="Account Settings" >
        <Preference
            android:key="profilePref"
            android:title="Your Profile" />
        <Preference
            android:key="passwordPref"
            android:title="Change Password" />
        <Preference
            android:key="privacyPref"
            android:title="Privacy Settings" />
    </PreferenceScreen>

    <Preference
        android:key="notificationPref"
        android:title="Notification Settings" />
    <Preference
        android:key="socialPref"
        android:summary="Facebook, Foursquare, Twitter"
        android:title="Social Connect" />

    <PreferenceCategory android:title="Device Settings" >
        <CheckBoxPreference
            android:defaultValue="true"
            android:key="pushPref"
            android:summary="Show on status bar when new notifications are recieved"
            android:title="Push Notifications" />
        <CheckBoxPreference
            android:defaultValue="true"
            android:dependency="pushPref"
            android:key="vibratePref"
            android:summary="Vibrate on incoming notifications"
            android:title="Vibrate" />
        <CheckBoxPreference
            android:defaultValue="true"
            android:dependency="pushPref"
            android:key="lightPref"
            android:summary="Pulse light for notification"
            android:title="Notification Light" />
    </PreferenceCategory>
    <PreferenceCategory android:title="Friends" >
        <Preference
            android:key="addFriendsPref"
            android:summary="Find friends on Bakasura"
            android:title="Add friends" />
        <Preference
            android:key="friendReqPref"
            android:summary="Approve pending friend requests"
            android:title="Friend  Requests" />
    </PreferenceCategory>
    <PreferenceCategory android:title="Troubleshooting" >
        <Preference
            android:key="helpPref"
            android:summary="Get help using Bakasura!"
            android:title="Help" />
        <Preference
            android:key="reportPref"
            android:summary="Send a force-close report by email"
            android:title="Send report" />
        <Preference
            android:key="cachePref"
            android:summary="sdfas"
            android:title="asdsa" />
    </PreferenceCategory>
    <PreferenceCategory android:title="About" >
        <PreferenceScreen
            android:key="aboutPrefScreen"
            android:summary="About, Terms of Service, Privacy Policy"
            android:title="About" >
            <Preference
                android:key="versionPref"
                android:summary="sadsa"
                android:title="Version" />

            <PreferenceCategory android:title="Legal" >
                <Preference
                    android:key="tosPref"
                    android:title="Terms of Service" />
                <Preference
                    android:key="privacyPolicyPref"
                    android:title="Privacy Policy" />
            </PreferenceCategory>
        </PreferenceScreen>
    </PreferenceCategory>
</PreferenceScreen>

清理项目并重试,否则重试

import package.name.R

我花了很多时间寻找同样的答案。
导入com.package.name.R;是什么最终解决了它。感谢您在这方面的帮助。

关于这一点,存在大量问题。你研究过他们的解决方案吗@云音乐是我做的。我只是在偏好活动中得到了这个,所以我发布了一个问题