【问题标题】:How to enable "Extract String Resource" popup in Android Studio?如何在 Android Studio 中启用“提取字符串资源”弹出窗口?
【发布时间】:2015-05-07 11:05:34
【问题描述】:

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

我需要什么来恢复那个弹出窗口吗? 这是弹出窗口现在的屏幕截图。

【问题讨论】:

    标签: android android-layout android-studio


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

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

      android:text="oh hi!"
      

      android:text="@string/this_doesnt_exist_yet"
      

      【讨论】:

      • 谢谢你:)。您回答的第一个选项为我工作。当我键入实际字符串时,会弹出“提取字符串资源”,并且可以在 strings.xml 中添加资源名称。它非常方便,因为可以避免不匹配。
      猜你喜欢
      • 2022-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-22
      • 1970-01-01
      • 1970-01-01
      • 2012-01-10
      • 1970-01-01
      相关资源
      最近更新 更多