有没有办法在Android Studio中使用自动生成的资源名称为Java文件提取字符串? [英] Is there a way to extract a string with an automatically generated resource name for a java file in Android Studio?

查看:355
本文介绍了有没有办法在Android Studio中使用自动生成的资源名称为Java文件提取字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android Studio中,Alt + Enter> Java文件中的提取字符串资源将打开以下窗口:

In Android Studio, Alt + Enter > "Extract String Resource" in a java file will open the following window:

请注意,资源名称字段为空白。但是,对于布局XML文件,该窗口将类似于以下内容:

Please note that the Resource name field is blank. However, the window will be like the following for a layout XML file:

请注意资源名称字段自动填充。

Please note the Resource name field is filled automatically.

如何用自动生成的Java文件名填充资源名称字段?

How can the Resource name field be filled with an automatically generated name for java files too?

它认为在当前版本的Android Studio(2.1)之前,所有类型的文件都自动填充了资源名称,但我可能是错的。

It thought the Resource name was filled automatically for all types of files before the current version of Android Studio (2.1), but I could be wrong.

2018-05-29:
我想强调的问题是关于自动生成的资源名称,而不是关于是否可以提取硬编码的字符串。从Java文件提取硬编码字符串始终可用,但是不存在自动名称生成功能。

[edit] 2018-05-29: I want to emphasize the question is about "automatically generated resource name", not about whether one can extract a hard-coded string. Extracting a hard-coded string from a java file has always been available, but the automatic name generation is not there.

推荐答案

您可以使用此软件自动执行此操作 https://www.jetbrains.com/help/idea/2016.2/recognizing-hard-coded-string-literals。 html

You can use this software to do this automatically https://www.jetbrains.com/help/idea/2016.2/recognizing-hard-coded-string-literals.html

链接有误(感谢给我不好的声誉),但是这个问题重复了很多次……

I had a mistake with the link (thanks for giving me a bad reputation) , however this question is duplicated many times...

我希望这对您有所帮助,下次,我们认为我们的时间仅用于帮助他人。祝你好运!

I hope this help you, and next time, think that we spend our time only for help other people. Good luck friend!

How can I find all RELEVANT hard coded strings in Android Studio?

在Android Studio中自动生成@String引用

Android:资源字符串自动生成

可以突出显示

How can I find all hard coded strings in my project in Android Studio

从Android代码中提取字符串到Intellij中的strings.xml文件的快捷方式是什么?

这篇关于有没有办法在Android Studio中使用自动生成的资源名称为Java文件提取字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆