2012-08-07 2 views
0

화면 하단에 탭을 배치하고 각 탭에 다른 활동을 표시하려고합니다.Android가 화면 하단에 탭이 있습니까?

그러나 내가 읽은 내용은 전화 3.0 이상에서만 사용할 수 있습니다.

내가 아는 대부분의 휴대 전화가 약 2.3 인 경우 약간 우스운 것 같습니다.

누구든지 아이디어가 있습니까?

+0

하단 탭은 iOS 디자인 패턴입니다. 그들은 안드로이드에서 꽤 외국인을 느낄 수 있습니다 : http://developer.android.com/design/patterns/pure-android.html – Krylez

+0

이 http://stackoverflow.com/questions/2395661/android-tabs-at-the- 아래쪽 – KMI

+0

그냥하지 마세요, 하지마. –

답변

0

조각과 하단에있는 일련의 단추를 사용하면이 작업을 가장 효과적으로 수행 할 수 있습니다.

그래서 버튼을 클릭하면 주 콘텐츠 영역에서 클릭 한 부분에 대해 조각 전환을 수행하십시오.

말하자면 Android의 하단 탭은 나쁜 형태입니다.

+0

단편을 조금 읽었을 때 ... <3.0 버전의 휴대 전화와 함께 사용할 수 있습니까? – droider

+0

예, 지원 라이브러리 jar를 사용합니다. 1.6 지원으로 돌아갑니다. –

1

이 ... 당신이 xml.I에서 몇 가지 여분의 코드는이 코드 조각이 이루어지고 당신을 도움이되기를 바랍니다 추가하기 만하면됩니다, 안드로이드 보통 탭을 사용하여 구현 될 수있다

<TabHost 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@android:id/tabhost" 
     android:background="@android:color/background_dark" 

> 

    <RelativeLayout 
     android:id="@+id/LinearLayout01" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" > 

     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent" 
      android:layout_height="match_parent" 
      android:layout_above="@android:id/tabs"> 
     </FrameLayout> 

     <TabWidget 
      android:id="@android:id/tabs" 
      style="@style/customtab" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 

      > 
     </TabWidget> 
    </RelativeLayout> 

</TabHost> 

스타일은 하단의 탭 표시 줄에 대한 XML 코드 아래

<style name="customtab" parent="@android:style/Widget.TabWidget"> 
      <item name="android:tabStripEnabled">false</item> 
      <item name="android:tabStripLeft">@null</item> 
      <item name="android:tabStripRight">@null</item> 
     </style> 
0

사용 스타일/customtab @ 여기에있다.

<?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" > 

    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" 
     android:padding="3dp" > 

     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_above="@android:id/tabs" 
      android:layout_weight="1" /> 

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

</TabHost> 

및 아래의 자바 코드를 사용하십시오.

public class MainActivity extends TabActivity { 
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 

       setContentView(R.layout.tab_screen); 
     TabHost tabHost = getTabHost(); 

     tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("Home", getResources().getDrawable(R.drawable.home)).setContent(new Intent(this, HomeActivity.class))); 

     tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("Second", getResources().getDrawable(R.drawable.invoice)).setContent(new Intent(this, SecondActivity.class))); 

     tabHost.setCurrentTab(0); 
    } 
} 
관련 문제