2012-11-18 2 views
0

내 응용 프로그램을 실행할 때이 매우 이상한 오류가 발생합니다. 내 탭 때문에 생각합니다. 여기에 오류 :XML 인플레이션 오류

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <LinearLayout 
     android:id="@+id/linearLayout1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:background="#ccc" > 

     <TextView 
      android:id="@+id/titleTV" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="5dp" 
      android:layout_marginLeft="10dp" 
      android:layout_marginTop="5dp" 
      android:text="Bytes" 
      android:textSize="20dp" /> 
    </LinearLayout> 

    <TabHost 
     android:id="@android:id/tabhost" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@id/linearLayout1" > 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical" > 

      <TabWidget 
       android:id="@android:id/tabs" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" > 
      </TabWidget> 

      <FrameLayout 
       android:id="@android:id/tabcontent" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" > 

       <LinearLayout 
        android:id="@+id/tab1" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" > 
       </LinearLayout> 

       <LinearLayout 
        android:id="@+id/tab2" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" > 
       </LinearLayout> 

       <LinearLayout 
        android:id="@+id/tab3" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" > 
       </LinearLayout> 
      </FrameLayout> 
     </LinearLayout> 
    </TabHost> 

</RelativeLayout> 

그리고 내에서 OnCreate 방법 : 전에이 오류를 본 적이 없다

super.onCreate(savedInstanceState); 
setContentView(R.layout.activity_main); 

tabHost = (TabHost)findViewById(android.R.id.tabhost); 
tabHost.setup(); 

TabSpec ts = tabHost.newTabSpec("Home").setIndicator("Home").setContent(new Intent().setClass(this,MainActivity.class)); 
tabHost.addTab(ts); 
ts = tabHost.newTabSpec("Quests").setIndicator("Quests").setContent(new Intent().setClass(this,Jobs.class)); 
tabHost.addTab(ts); 

tabHost.setCurrentTab(0); 

11-18 14:45:27.093: E/AndroidRuntime(680): FATAL EXCEPTION: main 
11-18 14:45:27.093: E/AndroidRuntime(680): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}:  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: android.view.InflateException: Binary XML file line #14: Error inflating class <unknown> 
11-18 14:45:27.093: E/AndroidRuntime(680): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) 
11-18 14:45:27.093: E/AndroidRuntime(680): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 
11-18 14:45:27.093: E/AndroidRuntime(680): at android.app.ActivityThread.access$2300(ActivityThread.java:125) 
11-18 14:45:27.093: E/AndroidRuntime(680): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 
11-18 14:45:27.093: E/AndroidRuntime(680): at android.os.Handler.dispatchMessage(Handler.java:99) 
11-18 14:45:27.093: E/AndroidRuntime(680): at android.os.Looper.loop(Looper.java:123) 
11-18 14:45:27.093: E/AndroidRuntime(680): at android.app.ActivityThread.main(ActivityThread.java:4627) 
11-18 14:45:27.093: E/AndroidRuntime(680): at java.lang.reflect.Method.invokeNative(Native Method) 
11-18 14:45:27.093: E/AndroidRuntime(680): at java.lang.reflect.Method.invoke(Method.java:521) 
11-18 14:45:27.093: E/AndroidRuntime(680): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 
11-18 14:45:27.093: E/AndroidRuntime(680): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 
11-18 14:45:27.093: E/AndroidRuntime(680): at dalvik.system.NativeStart.main(Native Method) 
11-18 14:45:27.093: E/AndroidRuntime(680): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.laytproducts.bytes.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.laytproducts.bytes/com.la 

여기 내 XML 파일입니다. 어떤 이유로 xml 파일에 문제가 발생 했습니까?
MainActivity 을 MainActivity와 탭에서 을 MainActivity와 탭에서 을 MainActivity와 탭에서 을 MainActivity와 탭에서 을 MainActivity에 :

+0

제목에 태그를 추가하지 마십시오. –

답변

1

당신은 부하에 시도하여 무한 루프를 작성하는 탭, 탭의 MainActivity와 에서 MainActivity와 탭 MainActivity와 탭 MainActivity와 탭 , , ,

이 귀찮은 라인 :

TabSpec ts = tabHost.newTabSpec("Home").setIndicator("Home").setContent(new Intent().setClass(this,MainActivity.class)); 

나는

어쨌든 당신은 새로운 클래스를 만들 필요가 ... 전체 로그 캣을 근본 원인이있는 StackOverflowException 보여줍니다 느끼는 것은, 그것을 호출했다 MainActivity가 탭을로드하고 Home이 기본 화면 인 "홈".

+0

고맙습니다. 나는 그 실수를 조금 어리 석 게 느낀다 : P – Brandon

+0

아무런 문제없이, 그것은 첨자 표기법을 남용 할 핑계가되었다. :) – Sam