在 Android Studio 0.4.0 中添加新首选项屏幕的选项在哪里?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20720667/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 03:21:40  来源:igfitidea点击:

Where is the option to add a new preference screen in Android Studio 0.4.0?

android

提问by ant2009

Android Studio 0.4.0

Hello,

你好,

I want to add a new Preference Screen in Android Studio. However, I cannot find the menu option to do it.

我想在 Android Studio 中添加一个新的首选项屏幕。但是,我找不到执行此操作的菜单选项。

In Eclipse you would right click the resource directory | New xml file | resource type (preferences)

在 Eclipse 中,您将右键单击资源目录 | 新建 xml 文件 | 资源类型(首选项)

However, when I try and do this in Android Studio, there is no resource type preferences.

但是,当我尝试在 Android Studio 中执行此操作时,没有资源类型preferences

Do I have to do this manually now?

我现在必须手动执行此操作吗?

Many thanks for any suggestions,

非常感谢您的任何建议,

采纳答案by user2511882

The preference option doesn't exist anymore. You will need to right click the res->new->Android resource fileand choose the resource type as xmlin the dropdown. Then you will manually need to add the layout for preference xml.

偏好选项不再存在。您需要右键单击res-> new->Android resource filexml在下拉列表中选择资源类型。然后您将需要手动添加首选项 xml 的布局。

回答by Randy

In Android Studio 1.1.0: If you create a SettingsActivity it automatically sets up some xml preference resource files for you.

在 Android Studio 1.1.0 中:如果您创建一个 SettingsActivity,它会自动为您设置一些 xml 首选项资源文件。

  1. Under src > main > java, right click a package (e.g. com.company.appname)
  2. New > Activity > Settings Activity
  3. Click Finish to accept the defaults
  4. Notice the new files:
    • SettingsActivity
    • values/strings_activity_settings.xml
    • xml (Directory)
      • pref_data_sync.xml
      • pref_general.xml
      • pref_headers.xml
      • pref_notification.xml
  1. 在 src > main > java 下,右键单击一个包(例如 com.company.appname)
  2. 新建 > 活动 > 设置活动
  3. 单击完成以接受默认值
  4. 注意新文件:
    • 设置活动
    • 值/strings_activity_settings.xml
    • xml(目录)
      • pref_data_sync.xml
      • pref_general.xml
      • pref_headers.xml
      • pref_notification.xml

Note: The Activity uses some deprecated code. It might be best to look at the latest documentation for creating a preferences activity: http://developer.android.com/reference/android/preference/PreferenceFragment.htmland for creating the XML resource file: http://developer.android.com/reference/android/preference/Preference.html

注意:Activity 使用了一些不推荐使用的代码。最好查看创建首选项活动的最新文档:http: //developer.android.com/reference/android/preference/PreferenceFragment.html和创建 XML 资源文件:http: //developer.android .com/reference/android/preference/Preference.html

回答by Reinhard Huber

What I just did was creating a new "Android resource directory" res->new->Android resource directory. There you choose xml, which creates the xml folder. Right click on this xml folder -> new -> XML resource file and then it proposes Preference Screen.

我刚刚做的是创建一个新的“Android 资源目录” res->new->Android 资源目录。在那里您选择 xml,这将创建 xml 文件夹。右键单击这个 xml 文件夹 -> 新建 -> XML 资源文件,然后它会建议首选项屏幕。

回答by Mallik Kumar

Try this in Android Studio 1.0.2. File ->New->Other. Select Activity->Settings Activity. Follow the wizard to add it to your application.

在 Android Studio 1.0.2 中试试这个。文件->新建->其他。选择活动->设置活动。按照向导将其添加到您的应用程序。

回答by Naveen

Right Click on Folder/Directory -> New -> Xml Resource File. Name the File and create. This will create Preference xml file.

右键单击文件夹/目录 -> 新建 -> Xml 资源文件。命名文件并创建。这将创建首选项 xml 文件。

回答by Sakib

In Windows, Go to Settings Then Double Click on Editor

在 Windows 中,转到设置然后双击编辑器

回答by d4rkcon

(For Windows, go to File > Settings > Editor > General) (For Mac, go to Android Studio > Preferences > Editor > General)

(对于 Windows,转到 File > Settings > Editor > General)(对于 Mac,转到 Android Studio > Preferences > Editor > General)

回答by Mike Hanafey

In AS 3.2, click on res/xml, type ALT INS, select XML Resource Fileand you get an empty PreferencesScreen

在 AS 3.2 中,点击res/xml,输入 ALT INS,选择XML Resource File你会得到一个空的PreferencesScreen