Android Studio - 资源菜单
Android Studio - Resources Menu
我是 android Studio 的新手。我在 canvas 上放置了一个 textView 小部件。
我正在学习一个教程,该教程指出我现在可以双击这个小部件,它应该会显示 "Resources Menu" - 然而这并没有发生。
最终目标是使用资源菜单提取字符串资源并自动将其放入 strings.xml。
任何人都可以阐明我将如何设置此菜单吗?
GF
为 textView 中使用的文本创建字符串资源的最简单方法是切换到布局的文本格式。您可以使用布局底部的选项卡在设计视图和文本视图之间切换。
然后,将光标放在要用 ID 替换的字符串上,单击 ALT+ENTER,然后再次输入 "Extract string resource":
这将调出字符串资源的属性:
在那里,您可以添加 "Resource Name"。执行此操作后,xml 中的字符串将被其 ID 替换:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hellostring" />
并且字符串的值现在将在 /res/values/strings 文件中,例如
<resources>
<string name="app_name">My Application</string>
<string name="action_settings">Settings</string>
<string name="hellostring">Hello World!</string>
</resources>
是的,正确答案是 "Then, put the cursor on the string you want to replace with an ID, click ALT+ENTER, then Enter again to "提取字符串资源":"
我是 android Studio 的新手。我在 canvas 上放置了一个 textView 小部件。
我正在学习一个教程,该教程指出我现在可以双击这个小部件,它应该会显示 "Resources Menu" - 然而这并没有发生。
最终目标是使用资源菜单提取字符串资源并自动将其放入 strings.xml。
任何人都可以阐明我将如何设置此菜单吗?
GF
为 textView 中使用的文本创建字符串资源的最简单方法是切换到布局的文本格式。您可以使用布局底部的选项卡在设计视图和文本视图之间切换。
然后,将光标放在要用 ID 替换的字符串上,单击 ALT+ENTER,然后再次输入 "Extract string resource":
这将调出字符串资源的属性:
在那里,您可以添加 "Resource Name"。执行此操作后,xml 中的字符串将被其 ID 替换:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hellostring" />
并且字符串的值现在将在 /res/values/strings 文件中,例如
<resources>
<string name="app_name">My Application</string>
<string name="action_settings">Settings</string>
<string name="hellostring">Hello World!</string>
</resources>
是的,正确答案是 "Then, put the cursor on the string you want to replace with an ID, click ALT+ENTER, then Enter again to "提取字符串资源":"