* 我正在处理它显示以下错误和异常的片段...在运行时...帮我解决这些错误和eception * 和模拟器也显示消息ui已停止..我是android编程的新手......
enter code here04-06 11:45:03.251: I/dalvikvm(707): threadid=3: reacting to signal 3
04-06 11:45:03.420: I/dalvikvm(707): Wrote stack traces to '/data/anr/traces.txt'
04-06 11:45:03.671: D/AndroidRuntime(707): Shutting down VM
04-06 11:45:03.671: W/dalvikvm(707): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
04-06 11:45:03.691: I/dalvikvm(707): threadid=3: reacting to signal 3
04-06 11:45:03.731: E/AndroidRuntime(707): FATAL EXCEPTION: main
04-06 11:45:03.731: E/AndroidRuntime(707): java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.example.android.fragments/com.example.android.fragments.MainActivity}:
android.view.InflateException: Binary XML file line #23: Error inflating class fragment
04-06 11:45:03.731: E/AndroidRuntime(707): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
04-06 11:45:03.731: E/AndroidRuntime(707): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
04-06 11:45:03.731:E/AndroidRuntime(707): at android.app.ActivityThread.access$600(ActivityThread.java:123)
04-06 11:45:03.731: E/AndroidRuntime(707): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
04-06 11:45:03.731:E/AndroidRuntime(707):at android.os.Handler.dispatchMessage(Handler.java:99)
04-06 11:45:03.731: E/AndroidRuntime(707):at android.os.Looper.loop(Looper.java:137)
04-06 11:45:03.731:E/AndroidRuntime(707):at android.app.ActivityThread.main(ActivityThread.java:4424)
04-06 11:45:03.731:E/AndroidRuntime(707):at java.lang.reflect.Method.invokeNative(Native Method)
04-06 11:45:03.731: E/AndroidRuntime(707):at java.lang.reflect.Method.invoke(Method.java:511)
04-06 11:45:03.731: E/AndroidRuntime(707): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-06 11:45:03.731:E/AndroidRuntime(707):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-06 11:45:03.731:E/AndroidRuntime(707):at dalvik.system.NativeStart.main(Native Method)
04-06 11:45:03.731:E/AndroidRuntime(707): Caused by: android.view.InflateException: Binary XML file line #23:
Error inflating class fragment
04-06 11:45:03.731: E/AndroidRuntime(707): at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
04-06 11:45:03.731: E/AndroidRuntime(707): at
android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
04-06 11:45:03.731: E/AndroidRuntime(707): at
android.view.LayoutInflater.inflate(LayoutInflater.java:489)
04-06 11:45:03.731: E/AndroidRuntime(707): at
android.view.LayoutInflater.inflate(LayoutInflater.java:396)
04-06 11:45:03.731: E/AndroidRuntime(707): at
android.view.LayoutInflater.inflate(LayoutInflater.java:352)
04-06 11:45:03.731: E/AndroidRuntime(707): at
04-06 11:45:03.731: E/AndroidRuntime(707): at android.app.Activity.setContentView(Activity.java:1835)
04-06 11:45:03.731: E/AndroidRuntime(707): at
com.example.android.fragments.MainActivity.onCreate(MainActivity.java:30)
04-06 11:45:03.731: E/AndroidRuntime(707): at android.app.Activity.performCreate(Activity.java:4465)
04-06 11:45:03.731: E/AndroidRuntime(707): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
04-06 11:45:03.731: E/AndroidRuntime(707): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
04-06 11:45:03.731: E/AndroidRuntime(707): ... 11 more
04-06 11:45:03.731: E/AndroidRuntime(707): Caused by: java.lang.IllegalStateException: Content view not yet
created
04-06 11:45:03.731: E/AndroidRuntime(707): at
android.support.v4.app.ListFragment.ensureList(ListFragment.java:328)
04-06 11:45:03.731: E/AndroidRuntime(707): at
android.support.v4.app.ListFragment.getListView(ListFragment.java:222)
04-06 11:45:03.731: E/AndroidRuntime(707): at
com.example.android.fragments.HeadlinesFragment.onCreate(HeadlinesFragment.java:107)
04-06 11:45:03.731: E/AndroidRuntime(707): at
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:834)
04-06 11:45:03.731: E/AndroidRuntime(707): at
android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1058)
04-06 11:45:03.731: E/AndroidRuntime(707): at
android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1156)
04-06 11:45:03.731: E/AndroidRuntime(707): at
android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:270)
4-06 11:45:03.731: E/AndroidRuntime(707): at a
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
04-06 11:03.731: E/AndroidRuntime(707): ... 21 more
04-06 11:45:03.781: I/dalvikvm(707): Wrote stack traces to '/data/anr/traces.txt'
04-06 11:45:04.201: I/dalvikvm(707): threadid=3: reacting to signal 3
04-06 11:45:04.241: I/dalvikvm(707): Wrote stack traces to '/data/anr/traces.txt'
04-06 11:45:04.351: I/dalvikvm(707): threadid=3: reacting to signal 3
04-06 11:45:04.361: I/dalvikvm(707): Wrote stack traces to '/data/anr/traces.txt'
04-06 11:45:20.781: I/Process(707): Sending signal. PID: 707 SIG: 9
答案 0 :(得分:1)
引起:android.view.InflateException:二进制XML文件行#23:错误扩充类片段
您在MainActivity中使用的第23行的XML文件中有错误。
引起:java.lang.IllegalStateException:尚未创建内容视图
错误的原因可能是您正在尝试查找尚未创建的视图。
片段的生命周期是(来源:http://developer.android.com/reference/android/app/Fragment.html)