Android find all hardcoded strings in code using Android Studio

前端 未结 4 475
轮回少年
轮回少年 2020-12-16 13:24

I want to find all hard-coded strings in my code to move them into strings.xml file for future localization. Such as :

Toast.ma         


        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-16 14:00

    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.

提交回复
热议问题