【问题标题】:PreferenceScreen on android studioandroid studio 上的 PreferenceScreen
【发布时间】:2015-09-18 05:05:56
【问题描述】:

PreferenceScreen 在 Android Studio 上是否仍然可用?我尝试创建一个 xml 文件夹,直到 res 文件夹并创建 preference.xml 文件,但它给了我以下错误:http://schemas.android.com/apk/res/android URI 未注册。 我应该把这个文件放在哪里?

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

    <EditTextPreference
        android:key="pref_key_username"
        android:summary="@string/pref_summary_username"
        android:title="@string/pref_title_username"
        android:defaultValue="@string/default_user" />
    <EditTextPreference
        android:key="pref_key_dbname"
        android:summary="@string/pref_summary_dbname"
        android:title="@string/pref_title_dbname"
        android:defaultValue="@string/default_dbname"  />
    <EditTextPreference
        android:key="pref_key_api_key"
        android:summary="@string/pref_summary_api_key"
        android:title="@string/pref_title_api_key"
        android:defaultValue="@string/default_api_key" />
    <EditTextPreference
        android:key="pref_key_api_password"
        android:summary="@string/pref_summary_api_password"
        android:title="@string/pref_title_api_password"
        android:defaultValue="@string/default_api_password" />

</PreferenceScreen>

【问题讨论】:

  • 你能粘贴你的目录结构的截图吗?
  • 添加截图供您参考:)
  • 错了。添加了答案:)

标签: android xml


【解决方案1】:

它不应该在 values 文件夹中。它应该在

res\xml\preference.xml

最好使用 Studio 中的“添加 Android XML”文件选项,而不是手动创建文件夹和文件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-08-05
    • 2012-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多