radio button 旁边放图片以及强制程序本地化以及string含有参数
<RadioButton android:id="@+id/RadioButton01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Text"
android:drawableLeft="@drawable/icon"
android:drawableRight="@drawable/icon"
android:drawableTop="@drawable/icon"
android:drawableBottom="@drawable/icon" />
?
有时候为了使版本能够适用不同的地区 而选择了不同文件夹
其实有时候还可以强制使用
<activity android:name=".M1" android:configChanges="locale" android:label="@string/app_name" />
一定要加上啊
然后呢代码
public void onCreate(Bundle savedInstanceState) {
? ? super.onCreate(savedInstanceState);
? ? String languageToLoad = "cn";
? ? Locale locale = new Locale(languageToLoad);
? ? Locale.setDefault(locale);
? ? Configuration config = new Configuration();
? ? config.locale = locale;
? ? getBaseContext().getResources().updateConfiguration(config,
? ? getBaseContext().getResources().getDisplayMetrics());
? ? this.setContentView(R.layout.main);
? }
剩下的就很简单了
你要做的就是 在main假设存在一个button,你想在上面设置文字 ,你想有英文的或者中文的,但是你想你手机使用的时候先强制使用中文
那么你只需要在
res中新建一个文件夹 values-cn 然后里面的参数和vvalues中的string一样就可以了 只要内容不同
然后你运行程序就会发现 原来先运行的是中文的
?
3.
?String msg = getResources().getString(R.string.text_c);???????
? msg = java.text.MessageFormat.format(msg, "foo", "bar", locale);
?
?
?<string name="text_c">This string uses message formatting. In the current locale, {1} comes before {0} and the current locale is {2}.</string>