在 Android Studio 中自动生成 @String 引用 [英] Auto Generate @String reference in Android Studio

查看:86
本文介绍了在 Android Studio 中自动生成 @String 引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这在 eclipse 中是可能的,按照这里的建议:Android:资源字符串自动一代

I know that this is possible in eclipse by following the advice here: Android: resource String automatic generation

但我似乎无法在 android studio 中找到这是否可行.有人知道怎么做吗?

But I can't seem to find if this is possible in android studio yet. Anybody know how to do this?

基本上我想采用硬编码的字符串并在我的主要 values.xml 或 strings.xml 中自动创建一个 @string 引用.

Basically I would like to take a hardcoded string and auto create a @string reference in my main values.xml or strings.xml.

推荐答案

Alt+Enter, Extract String Resource而插入符号在里面硬编码字符串:

Alt+Enter, Extract String Resource while the caret is inside the hardcoded string:

同样适用于 XML 文件,它适用于 IntelliJ IDEA,但似乎在当前版本的 Android Studio 中被破坏:

The same should work in XML files as well, and it does work in IntelliJ IDEA, but seems to be broken in the current version of the Android Studio:

Android Studio 0.1.3 显示了它从字符串资源中提取的 XML 布局中的折叠文本,但它无法导航回资源并且不提供从 XML 内的硬编码字符串中提取资源.这似乎是一个错误.

Android Studio 0.1.3 shows the folded text in XML layouts that it extracts from the string resources, but it fails to navigate back to the resource and doesn't offer to extract resources from the hardcoded strings inside XML. It appears to be a bug.

这篇关于在 Android Studio 中自动生成 @String 引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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