I want to find all hard-coded strings in my code to move them into strings.xml
file for future localization. Such as :
Toast.makeText(context,"Hardcoded text",LENGTH_SHORT).show();
I using Android Studio.
I want to find all hard-coded strings in my code to move them into strings.xml
file for future localization. Such as :
Toast.makeText(context,"Hardcoded text",LENGTH_SHORT).show();
I using Android Studio.
Go to
Analyze
>Run Inspection By Name...
(Ctrl+Alt+Shift+I)and type:
Hardcoded Text
to find the hardcoded strings in the .xml files;Hardcoded Strings
to find the hardcoded strings in the .java files.Run it against the whole project, and you should get an inspection results panel that will show the hardcoded text instances.
This answer hasn't getting to me any result.
Nonetheless, for future searches :
In Android Studio 1.2.2 added new Option
Hardcoded strings
(not aHardcoded text
) and this getting to me perfect searches result.After android studio 1.2.2 It seems pretty easy way to do it,
Go to Analyze
Run Inspection by name
Type : HardCoded Text
And then by selecting appropriate module's option you can get all hard coded Strings in your whole project.
Tip : Short key :
Ctrl
+Alt
+Shift
+I
It seems it has been already answered here, isn't it relevant for your problem ? Edit : just don't forget to check "File mask(s)" box in the window after having typed "Hardcoded text", and select
*.java
, if you want to search in Java files.And after you found all your hardcoded strings, this may help you to transfer them to XML.