2011-08-18 3 views
0

세 가지 활동으로 연결된 세 개의 탭이 포함 된 탭 호스트가 있습니다. 세 개의 탭 모두 위쪽에 있습니다. 이 세 개의 탭을 어떻게 아래쪽에 만들 수 있습니까?하단에 탭을 추가하는 방법

나는 이것을 발견했지만 여전히 몇 가지 문제가있다.

이 내 tabhost의 XML 파일입니다

내 TabActivity 클래스에서
<?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"> 
    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 
     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_weight="1" /> 
     <TabWidget 
      android:id="@android:id/tabs" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="0"/> 
    </LinearLayout> 
</TabHost> 

, 내가 다음 코드를했다 : 나는 또한 매니페스트 파일에 포함 된 한 TabActivity1라는 이름의 하나 개의 활동이 있습니다

setContentView(R.layout.tabs); 

TabHost mTabHost = (TabHost)findViewById(android.R.id.tabhost); 

mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator("TAB 1").setContent(new Intent(AndroisTabViewActivity.this,TabActivity1.class))); 
mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("TAB 2").setContent(new Intent(AndroisTabViewActivity.this,TabActivity1.class))); 
mTabHost.addTab(mTabHost.newTabSpec("tab_test3").setIndicator("TAB 3").setContent(new Intent(AndroisTabViewActivity.this,TabActivity1.class))); 

mTabHost.setCurrentTab(0); 

. 단지 이것을 시도, 난 당신이 윈도우의 하단에서 "탭"을 보여주고 싶은 생각

Can't get the activity TabActivity1.

+0

Manifest 파일에 AndroisTabViewActivity가 포함되어 있습니까? 어떤 종류의 오류가 발생했는지 보여주십시오. 아마 매니페스트에 활동을 등록하는 것과 관련이 없을 수도 있습니다. – Kostas

+0

예 매니 페스트 파일에 포함 시켰습니다. 로그 고양이 사진을 얻는 방법을 모릅니다. 오류를 기록합니다. 잠시 기다려주십시오. –

+0

다음은 내 오류입니다. activityComponentInfo {com.mirza.tabViewDemo/com.mirza.tabViewDemo.AndroisTabViewActivity}를 시작할 수 없습니다. android.content.ActivityNotFoundException 명시 적 활동 클래스 {com.mirza.tabViewDemo/com.mirza.tabViewDemo.TabActivity1} –

답변

1

: 그러나 오류를 보여주는

<RelativeLayout 
    android:layout_width="match_parent" 
    android:id="@+id/linearLayout1" 
    android:layout_height="match_parent"> 

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

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

+0

고맙습니다. 귀하의 코드도 잘 돌아갔습니다. 나는 매니 페스트 파일에 잘못 입력했습니다. 나는 활동 대신 행동을 타이핑했다. 미안하다. :디 –

0

사용하려는 경우 LinearLayout :

이 솔루션을
<?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"> 
    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 
     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1" /> 
     <TabWidget 
      android:id="@android:id/tabs" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" /> 
    </LinearLayout> 
</TabHost> 

tab content가 먼저 어떤 공간을 차지하지 않습니다는 TabWidget가 자신의 공간을 차지합니다, 다음 나머지 공간은 tab content 주어집니다.

관련 문제