【问题标题】:How can I remove unused string resource items in a simple way in Android Studio? [duplicate]如何在 Android Studio 中以简单的方式删除未使用的字符串资源项? [复制]
【发布时间】:2016-09-24 05:07:34
【问题描述】:

我知道我可以使用快捷键 Ctrl+Alt+O 来删除 Android Studio 中不必要的导入。

现在我的资源文件里有很多字符串资源名,比如strings.xml,但是有些字符串资源名在我的项目中使用得比较神经。

有没有一种简单的方法可以删除这些未使用的字符串资源名称。

目前我必须手动删除项目<string name="ExpiredWarning">Warning</string>,如果我发现我不再需要它。

Strings.xml

<resources>
    <string name="app_name">Screen Recorder</string>



    <string name="BtnBuy">Purchase</string>
    <string name="BtnRetrieve">Retrieve</string>
    <string name="BuyPrompt">This is a trial version. It will be fully functional for 15 days. You can upgrade to the unlimited version and remove banner ads via an in-app purchase.</string>
    <string name="RetrievePrompt">If you have purchased the app, please click \'Retrieve\' button to recover.</string>
    <string name="MsgBillError">Problem setting up in-app billing: </string>
    <string name="MsgBillINI">An error occurred when initialize billing!</string>
    <string name="MsgOrderError">Purchasing error: </string>
    <string name="MsgOrderOK">You have purchased successfully! Please close and restart the app !</string>
    <string name="MsgInventoryFail">Failed to query inventory: </string>
    <string name="MsgRetrieveOK">You have retrieved your order info successfully! Please close and restart the app !</string>
    <string name="MsgRetrieveFail">You havn\'t purchased the app, please click \'Purchase\' button</string>
    <string name="ExpiredWarning">Warning</string>
    <string name="ExpiredTitle">The app expired, you can upgrade to the unlimited version and remove banner ads via an in-app purchase.</string>

</resources>

【问题讨论】:

标签: android android-studio


【解决方案1】:

简单的解决方案是

从顶部栏中选择重构 -> 删除未使用的资源

【讨论】:

  • 您不必为此打开 strings.xml
  • @TimCastelijns 我已经更新了答案 :) 感谢您的纠正
猜你喜欢
  • 2015-05-10
  • 2018-10-12
  • 1970-01-01
  • 1970-01-01
  • 2013-02-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多