如何通过我的textView1从字符串资源中textView2 getText进行等效字符串名称
“如果TextView1中的值是等于字符串名称,我希望字符串显示TextView2” //字符串示例
<string name="a">Apple</string>
<string name="b">Banana</string>
<string name="c">Car</string>
//示例 如果textview1 = a textview2将显示苹果
"If the value in textView1 is equal string name I want string to show textView2"
// String Example
<string name="a">Apple</string>
<string name="b">Banana</string>
<string name="c">Car</string>
//Example
if textView1 = a
textView2 Will Show Apple
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在这里,您将
StringName
作为textView1
的文本。您可以通过
stringname
从资源上从编程中获取字符串值。step1
:首先获取两个值,然后将其存储在变量中;使用此方法获取字符串值。
您也可以通过
log.e
检查此值。step2
:现在在textView2
中设置strvalue
。Here you have
stringName
as a text in yourtextView1
.You can
fetch String value
programatically from resourses bystringName
.Step1
: first fetch this both values, and store it in a variable;use this method to fetch String value.
You can also check this values via
Log.e
.Step2
: Now set yourstrValue
in yourtextView2
.尝试使用getIdentifier()getResources()的方法如下。
从
Try using getIdentifier() method of getResources() like below.
Referenced from https://stackoverflow.com/a/17086690/9502601