如何在 Android Studio 中启用“提取字符串资源”弹出窗口?

Nik*_*A A 9 android android-layout android-studio

在Android Studio中,在布局xml文件中添加TextView时,可以非常方便地使用“提取字符串资源”将字符串名称添加到strings.xml中。但不知何故,无论我单击还是按 Alt + Enter(Windows 8 操作系统),它都不会出现在弹出窗口中。

我需要做什么才能恢复该弹出窗口吗?这是弹出窗口现在的屏幕截图。

在此输入图像描述

Fun*_*onk 6

当属性是您想要的字符串值或不存在的字符串引用时执行操作,例如:

android:text="oh hi!"
Run Code Online (Sandbox Code Playgroud)

或者

android:text="@string/this_doesnt_exist_yet"
Run Code Online (Sandbox Code Playgroud)


sco*_*ttt 6

如果在字符串文字上按 Alt-Enter 时该选项没有出现,则可能已将其禁用。在 Android Studio 3.1.4 中,可以通过选择Help/Find Action...(Ctrl-Shift-A) 并搜索“提取字符串资源”来启用它。设置的实际路径是File/Settings/Editor/Intentions/Android/Extract string resource。无论哪种方式,您都需要启用它。