2009-12-15 3 views
2

내 Android 용 TabActivity를 만들려고합니다. 내 레이아웃 XML이 2 개의 탭에 대해 더미 TextView 내용과 함께 다음과 같이 나타나면 모든 것이 잘 보입니다.TabActivity/TabWidget의 Android 오류

<?xml version="1.0" encoding="utf-8"?> 
<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/tabhost" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:paddingTop="3px"> 

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

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

     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:padding="10px"> 

      <TextView android:id="@+id/login_form" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="DUMMY LOGIN FORM" /> 
      <TextView android:id="@+id/register_form" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="DUMMY REGISTER FORM" /> 

     </FrameLayout> 
    </LinearLayout> 
</TabHost> 

각 TextView를 여러 View 요소가 포함 된 LinearLayout으로 바꾸고 싶습니다. 하지만 TextView 행을 다음과 같이 바꾸려고하면 즉시 강제 종료 창이 나타납니다.

<LinearLayout android:id="@+id/login_form" android:layout_width="fill_parent" layout_height="fill_parent" android:orientation="vertical"> 
    <TextView android:id="@+id/username_label" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/username" /> 
</LinearLayout> 
<LinearLayout android:id="@+id/register_form" android:layout_width="fill_parent" layout_height="fill_parent" android:orientation="vertical"> 
    <TextView android:id="@+id/username_desired_label" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/username_desired" /> 
</LinearLayout> 

왜 강제 폐쇄가 발생합니까? LinearLayout 이외의 다른 View를 사용하여 탭 컨텐츠를 함께 그룹화해야합니까?

편집 : 경우 내 문제, 내가 확장하고있는 TabActivity 클래스와 관련이 있으며, 내 onCreate 방법처럼 보인다 다음

protected void onCreate(Bundle savedInstanceState) { 
    // display the login/register view 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.login_register); 

    // associate the tab content with each tab, and specify the tab headers 
    setDefaultTab(0); 
    TabHost tabs = getTabHost(); 
    tabs.addTab(tabs.newTabSpec("login").setIndicator(getResources().getText(R.string.login)).setContent(R.id.login_form)); 
    tabs.addTab(tabs.newTabSpec("register").setIndicator(getResources().getText(R.string.register)).setContent(R.id.register_form)); 
} 

편집 : 요청으로가 여기 스택의 -trace 만 판독 오류 메시지와 함께 "소스를 찾을 수 없습니다."

스레드 [< 3> 주 (정지됨 (예외 RuntimeException의)) ActivityThread.performLaunchActivity (ActivityThread $ ActivityRecord, 의도) 라인 : 2401 ActivityThread.handleLaunchActivity (ActivityThread $ ActivityRecord, 의도) 라인 : 2417 ActivityThread.access $ 2100 (ActivityThread, ActivityThread $ ActivityRecord, 의도) 라인 116 ActivityThread $ H.handleMessage (메시지) 라인 : 1,794 ActivityThread $ H (핸들러) .dispatchMessage (메시지) 라인 99 Looper.loop() 선 123 ActivityThread.main (문자열 []) 라인 : 4203 Method.invokeNative (Object, Object [], Class, Class [], Class, int, 부울) 라인 : 사용할 수 없습니다 [기본 방법] Method.invoke (개체 객체 ...) 라인 : 521 ZygoteInit $ MethodAndArgsCaller.run() 라인 : 791 ZygoteInit.main (문자열 []) 라인 : 549 NativeStart.main (String []) 줄 : 사용할 수 없음 [기본 메소드]

+2

스택 추적이란 무엇입니까? 여기에 게시 할 수 있습니까? – Bostone

답변

0

와우, 나는 바보입니다. LinearLayout 선언에서 그들은 모두 android:layout_height 속성 대신에 layout_height 속성을 포함했습니다. 내 부분에 어리석은 감시, 나는 다시 그 실수를하지 않을 것입니다.

시간을내어 주셔서 감사합니다. DroidIn.net.