简体   繁体   中英

android how to change the app_name dynamically

Is it possible to change the app_name value in String.xml? not just setTitle();

I know there is a difference of languages may have mutiple xml files but i still want to change the

<string name="app_name">MyApp</string>

to

<string name="app_name">Good</string>

Is there any way to handle this? thank you

Like Ahmad said, there is no way to do this. But just wanted to point out for you that the res folder is a read-only , so you can't write anything to this programmatically like you wanted to.

A solution would just to set a variable to equal your app_name string. And then have the ActionBar or whereever you plan on using the app_name string, just replace it with the variable you defined before.

Then you can change it at will. Just note that if this is for the actionbar you'll have to make sure to update the action bar after the variable changes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM