Android extract string resource from layout xml file

人走茶凉 提交于 2019-12-05 20:01:51

I just found how to activate this feature.

Simply press "crtl+1" and the menu will pop out.

I was searching for this feature too until i found your post....

Thank you for the video too.

I am not really sure what you are trying to do but i'd like to give you some tips and I hope that this is going to answer your question.

First you should write any Strings which do not change at runtime in your project/res/value/strings.xml

An strings.xml entry example:

    <string name="text_button">Any Text</string>

Now you can access this string in your XML like that:

    android:text="@string/text_button" />

However, you'd like to access this string at runtime? Then try this:

TextView tv_1 = (TextView) findViewById(R.id.text1);
String myText = tv_1.getText();

And read this: http://developer.android.com/guide/topics/resources/accessing-resources.html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!