두 개의 탭으로 탭 위젯을 만들어 두 개의 다른 액티비티를 열고 이것을 달성하기 위해 레이아웃을 작성했지만 NullPointerException
이되었습니다.TabWidget NullpointerException?
내 실수는 어디에서 왔습니까? TabWidget
을 확장하는 자바 클래스에서
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<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="fill_parent">
</FrameLayout>
</LinearLayout>
</TabHost>
내가 가지고있는
onCreate
방법에 다음 코드 :
setContentView(R.layout.more);
TabHost mTabHost = (TabHost) this.findViewById(R.id.tabhost);
mTabHost.setup();
Intent intent;
intent = new Intent().setClass(this, Settings.class);
mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator(
"Calculator",
getResources().getDrawable(R.drawable.tab01)).setContent(intent));
intent = new Intent().setClass(this, Post.class);
mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator(
"YouTube",
getResources().getDrawable(R.drawable.tab02)).setContent(intent));
Eclipse에서 'adb logcat', DDMS 또는 DDMS 퍼스펙티브를 사용하여 스택 추적을 검사하면 문제가있는 위치를 알 수 있습니다. – CommonsWare
02-18 11 : 08 : 01.197 : INFO/ActivityManager (52) : 활동 시작 : 의도 {cmp = com.example.FindItear/.more} 02-18 11 : 08 : 11.224 : WARN/ActivityManager (52) : 시작 시간 제한이 만료되어 잠자기 잠금을 포기했습니다. 02-18 11 : 08 : 11.368 : WARN/ActivityManager (52) : HistoryRecord {43dba948 com.example.FindItNear /. More}의 활동 유휴 시간 초과 – UMAR
게시물에 대한 편집 내용으로 의견을 추가하십시오 (서식을 지정할 수 있도록). 그리고 더 쉽게 읽을 수) – KevinDTimm