I try to extract hardcoded strings from xml file but always got an error. Select hardcoded text, ctrl+1 , extract android string and this error pops instead of Android Extract String pop-up.
"The attribute android:text does not accept a string reference"...
Why do i get this error any tips?
I work with eclipse 3.7.1 and adt v16, operating system windows 7.
Added video that shows the feature http://www.youtube.com/watch?feature=player_embedded&v=Oq05KqjXTvs#t=1881s
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
来源:https://stackoverflow.com/questions/9302636/android-extract-string-resource-from-layout-xml-file