2013-04-23 2 views
-2

Android 개발을 배우고 있습니다. 현재 기본 탭 화면 설정을 시도하고 있습니다. 나는이 레이아웃을로드하는 활동을 실행하려고하면, I라는 오류가 나타납니다Android에서 기본 탭 설정이 작동하지 않습니다.

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:background="#fff" 
    android:layout_height="fill_parent"> 
    <RelativeLayout 
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:background="#2D2D2D" 
    android:layout_height="50dip" 
    android:minHeight="50dip"> 
     <LinearLayout 
     android:orientation="horizontal" 
     android:minWidth="25px" 
     android:minHeight="25px" 
     android:layout_width="wrap_content" 
     android:layout_height="fill_parent" 
     android:layout_centerHorizontal="true" 
     android:gravity="center" 
     android:id="@+id/linearLayout1"> 
    <TextView 
      android:text="@string/my" 
      android:textAppearance="?android:attr/textAppearanceSmall" 
      android:layout_weight="1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/textView1" 
      android:layout_marginRight="0.0dp" 
      android:textColor="#ffefc6" 
      android:textSize="22dip" 
      android:editable="false" 
      android:focusable="false" /> 
    <TextView 
      android:text="@string/app" 
      android:textAppearance="?android:attr/textAppearanceSmall" 
      android:layout_weight="1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/textView2" 
      android:textColor="#FFFFFF" 
      android:textSize="22dip" 
      android:editable="false" 
      android:focusable="false" /> 
     </LinearLayout> 
    </RelativeLayout> 

    <TabHost android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:id="@+id/tabHost"> 
    <RelativeLayout android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:padding="3dp"> 
     <TabWidget android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
    android:id="@android:id/tabs" 
    android:layout_alignParentBottom="true" /> 

     <FrameLayout android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:id="@android:id/tabcontent" 
     android:layout_alignParentTop="true"> 

      <LinearLayout android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/tab1" 
     android:orientation="vertical"> 
      <TextView android:layout_width="fill_parent" 
      android:layout_height="100px" 
      android:text="This is tab1" 
      android:id="@+id/txt1"/> 
     </LinearLayout> 

     <LinearLayout android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/tab2" 
     android:orientation="vertical"> 

     <TextView android:layout_width="fill_parent" 
      android:layout_height="100px" 
      android:text="This is tab2" 
      android:id="@+id/txt2"/> 
      </LinearLayout> 

     <LinearLayout android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/tab3" 
     android:orientation="vertical"> 
      <TextView android:layout_width="fill_parent" 
      android:layout_height="100px" 
      android:text="This is tab3" 
      android:id="@+id/txt3"/> 
     </LinearLayout> 
    </FrameLayout> 
    </RelativeLayout> 
    </TabHost> 
</LinearLayout> 

:이 작업을 수행하기위한 시도에서, 나는 다음과 같은 axml 만들었습니다. "응용 프로그램이 예기치 않게 중지를 시도하십시오 다시.". 이 코드의 문제점은 무엇입니까? 그것은 단순해야합니다. 나는이 시점에서 5 시간 동안 그것을 꼼짝 않고 바라 보았다. 이제 나는 그 문제를보기에는 너무 가깝다고 생각한다. 어떤 도움이라도 대단히 감사합니다.

+1

후 로그 캣 통해 UR 자바 코드를 시도 할 수 있습니다 – Senthil

답변

0

내가 무슨 잘못이와를 잘 모릅니다하지만 당신은 또한 같은 코딩에 의해

TabHost tabHost = getTabHost(); 

TabSpec Spec1 = tabHost.newTabSpec("Tab 1"); 
Spec1.setIndicator("Name of Tab 1"); 
Intent IntentTab1 = new Intent(this, tab1.class); 
Spec1.setContent(IntentTab1); 

TabSpec Spec2 = tabHost.newTabSpec("Tab 2"); 
Spec2.setIndicator("Name of Tab 2"); 
Intent IntentTab2 = new Intent(this, tab2.class); 
Spec2.setContent(IntentTab2); 


TabSpec Spec3 = tabHost.newTabSpec("Tab 3"); 
Spec3.setIndicator("Name of Tab 3"); 
Intent IntentTab3 = new Intent(this, tab3.class); 
Spec3.setContent(IntentTab3); 


tabHost.addTab(Spec1); 
tabHost.addTab(Spec2); 
tabHost.addTab(Spec3); 
관련 문제