以下作品:
Configuration newConfig = new Configuration();
newConfig.locale = Locale.US;
//newConfig.locale = new Locale("sv"); // swedish
onConfigurationChanged(newConfig);
以下请点击我的应用:
Configuration newConfig = new Configuration();
//newConfig.locale = Locale.US;
newConfig.locale = new Locale("sv"); // swedish
onConfigurationChanged(newConfig);
我有以下值文件夹:
values-en-rUS/strings.xml
values-sv/strings.xml
两个strings.xml都包含完全相同的文本。
我怀疑我要么命名我的值文件夹不正确,要么“sv”不正确。
这是logcat,我告诉你它不会帮助你......
06-05 21:52:07.933: E/AndroidRuntime(30944): android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout
06-05 21:52:07.933: E/AndroidRuntime(30944): at android.view.LayoutInflater.createView(LayoutInflater.java:620)
06-05 21:52:07.933: E/AndroidRuntime(30944): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
06-05 21:52:07.933: E/AndroidRuntime(30944): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
06-05 21:52:07.933: E/AndroidRuntime(30944): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
06-05 21:52:07.933: E/AndroidRuntime(30944): at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
06-05 21:52:07.933: E/AndroidRuntime(30944): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
06-05 21:52:07.933: E/AndroidRuntime(30944): at se.busarama.app.fragment.FragmentRight.onCreateView(FragmentRight.java:36)
06-05 21:52:07.933: E/AndroidRuntime(30944): at android.support.v4.app.Fragment.performCreateView(Fragment.java:1500)
06-05 21:52:07.933: E/AndroidRuntime(30944): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:927)
06-05 21:52:07.933: E/AndroidRuntime(30944): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
06-05 21:52:07.933: E/AndroidRuntime(30944): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
06-05 21:52:07.933: E/AndroidRuntime(30944): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)
06-05 21:52:07.933: E/AndroidRuntime(30944): at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:440)
06-05 21:52:07.933: E/AndroidRuntime(30944): at android.os.Handler.handleCallback(Handler.java:730)
06-05 21:52:07.933: E/AndroidRuntime(30944): at android.os.Handler.dispatchMessage(Handler.java:92)
06-05 21:52:07.933: E/AndroidRuntime(30944): at android.os.Looper.loop(Looper.java:137)
06-05 21:52:07.933: E/AndroidRuntime(30944): at android.app.ActivityThread.main(ActivityThread.java:5103)
06-05 21:52:07.933: E/AndroidRuntime(30944): at java.lang.reflect.Method.invokeNative(Native Method)
06-05 21:52:07.933: E/AndroidRuntime(30944): at java.lang.reflect.Method.invoke(Method.java:525)
06-05 21:52:07.933: E/AndroidRuntime(30944): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
06-05 21:52:07.933: E/AndroidRuntime(30944): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
06-05 21:52:07.933: E/AndroidRuntime(30944): at dalvik.system.NativeStart.main(Native Method)
06-05 21:52:07.933: E/AndroidRuntime(30944): Caused by: java.lang.reflect.InvocationTargetException
06-05 21:52:07.933: E/AndroidRuntime(30944): at java.lang.reflect.Constructor.constructNative(Native Method)
06-05 21:52:07.933: E/AndroidRuntime(30944): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
06-05 21:52:07.933: E/AndroidRuntime(30944): at android.view.LayoutInflater.createView(LayoutInflater.java:594)
06-05 21:52:07.933: E/AndroidRuntime(30944): ... 21 more
06-05 21:52:07.933: E/AndroidRuntime(30944): Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x1
06-05 21:52:07.933: E/AndroidRuntime(30944): at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:463)
06-05 21:52:07.933: E/AndroidRuntime(30944): at android.view.View.<init>(View.java:3374)
06-05 21:52:07.933: E/AndroidRuntime(30944): at android.view.View.<init>(View.java:3293)
06-05 21:52:07.933: E/AndroidRuntime(30944): at android.view.ViewGroup.<init>(ViewGroup.java:451)
06-05 21:52:07.933: E/AndroidRuntime(30944): at android.widget.RelativeLayout.<init>(RelativeLayout.java:242)
06-05 21:52:07.933: E/AndroidRuntime(30944): ... 24 more