错误处理日志:
09-03 16:55:16.820:E/AndroidRuntime(16873): FATAL EXCEPTION: main
09-03 16:55:16.820:E/AndroidRuntime(16873): Process: com.clockrock.freeshare, PID: 16873
09-03 16:55:16.820: E/AndroidRuntime(16873):java.lang.NullPointerException
09-03 16:55:16.820:E/AndroidRuntime(16873): atandroid.support.v4.app.BackStackRecord.doAddOp(BackStackRecord.java:416)
09-03 16:55:16.820:E/AndroidRuntime(16873): atandroid.support.v4.app.BackStackRecord.replace(BackStackRecord.java:451)
09-03 16:55:16.820:E/AndroidRuntime(16873): atandroid.support.v4.app.BackStackRecord.replace(BackStackRecord.java:443)
09-03 16:55:16.820:E/AndroidRuntime(16873): atcom.clockrock.freeshare.StartActivity.onCheckedChanged(StartActivity.java:477)
09-03 16:55:16.820:E/AndroidRuntime(16873): atandroid.widget.RadioGroup.setCheckedId(RadioGroup.java:174)
09-03 16:55:16.820:E/AndroidRuntime(16873): atandroid.widget.RadioGroup.access$600(RadioGroup.java:54)
09-03 16:55:16.820: E/AndroidRuntime(16873): atandroid.widget.RadioGroup$CheckedStateTracker.onCheckedChanged(RadioGroup.java:358)
09-03 16:55:16.820:E/AndroidRuntime(16873): atandroid.widget.CompoundButton.setChecked(CompoundButton.java:130)
09-03 16:55:16.820: E/AndroidRuntime(16873): atandroid.widget.CompoundButton.toggle(CompoundButton.java:87)
09-03 16:55:16.820:E/AndroidRuntime(16873): atandroid.widget.RadioButton.toggle(RadioButton.java:76)
09-03 16:55:16.820:E/AndroidRuntime(16873): atandroid.widget.CompoundButton.performClick(CompoundButton.java:99)
09-03 16:55:16.820:E/AndroidRuntime(16873): atandroid.view.View$PerformClick.run(View.java:19385)
09-03 16:55:16.820:E/AndroidRuntime(16873): atandroid.os.Handler.handleCallback(Handler.java:808)
09-03 16:55:16.820:E/AndroidRuntime(16873): atandroid.os.Handler.dispatchMessage(Handler.java:103)
09-03 16:55:16.820:E/AndroidRuntime(16873): atandroid.os.Looper.loop(Looper.java:193)
09-03 16:55:16.820:E/AndroidRuntime(16873): atandroid.app.ActivityThread.main(ActivityThread.java:5348)
09-03 16:55:16.820:E/AndroidRuntime(16873): atjava.lang.reflect.Method.invokeNative(Native Method)
09-03 16:55:16.820:E/AndroidRuntime(16873): atjava.lang.reflect.Method.invoke(Method.java:515)
09-03 16:55:16.820:E/AndroidRuntime(16873): atcom.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
09-03 16:55:16.820:E/AndroidRuntime(16873): atcom.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
09-03 16:55:16.820:E/AndroidRuntime(16873): atdalvik.system.NativeStart.main(Native Method)
第358行代码是这样的:红色标记
case 0: fragment = fragments.get(0);//对应编号为0的fragment transaction.replace(R.id.main_framelayout, fragment); transaction.commit(); title.setText("国内"); break;
错误原因是:fragment在使用的时候没有new 我就直接fragments.add(fragment)了
第二个错误:Call requires API level 11 (current min is 8): android.widget.AbsListView#setAdapter
改 android:minSdkVersion="14"为11以上,我改成了14