주 활동을 위해 개별 탭에 다른 레이아웃 파일을 사용하고 있습니다. 나는 꽤 바뀌었다. 처음에 wrap_content에 tab2.xml의 상대 레이아웃을 만들려고했으나 도움이되지 않았습니다. 내가 포함 파일의 ID를 변경하고 자바 코드에서 호출, 작동하지 않았다. 나는 가장 명백한 것들을 시도했다. 자, 나는 무엇이 잘못되었는지 전혀 모른다. 또한 이전에 이렇게했는데 tab2.xml의 높이와 너비가 match_parent 모드에 있으면 제대로 작동했습니다. 지금 프로그램 응용 프로그램. 디버그 콘솔에 표시되는 코드 줄은 "setContentView (R.layout.activity);"입니다. 따라서 레이아웃 파일과 코드에서 앱이 충돌하는 것은 분명합니다.다른 레이아웃 파일의 탭으로 인해 앱이 다운되는 경우가 발생했습니다.
여기에 주요 활동의 XML 코드가있다 : 여기
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/tab2"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".CleanUp" >
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/textView1"
android:layout_marginTop="40dp"
android:layout_marginRight="20dp"
android:inputType="text"
android:ems="10" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/editText1"
android:layout_alignBottom="@+id/editText1"
android:layout_alignParentLeft="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="10dp"
android:text="Custom extension:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="Clean" />
</RelativeLayout>
내가 내 활동 클래스의 탭을 위해 사용하고 코드입니다 : "activity.xml"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:context=".CleanUp" >
<TabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
<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"
android:background="@style/MyTheme" >
</TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<include layout="@layout/tab2"/>
</FrameLayout>
</LinearLayout>
</TabHost>
</RelativeLayout>
여기 tab2.xml입니다 :
TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost);
tabHost.setup();
TabSpec tab1 = tabHost.newTabSpec("Clean Up");
tab1.setIndicator("Clean up");
tab1.setContent(R.id.tab2);
tabHost.addTab(tab1);
로그 캣 오류
후 당신의 로그 캣 오류하시기 바랍니다. – Sam
pastebin 링크를 로그에 게시했습니다. –