2013-02-14 2 views

답변

0

http://jqueryui.com/tabs/

이것이 도움이 될 수 있습니다. 또는 너 자신을위한 커스텀 탭 컨트롤을 만들 수도 있습니다.

+0

형제 나는이 대답을 수락 anroid –

+0

@MehulRanpara 하하하 하하하 –

1

2 개월 전 같은 요구 사항이 있습니다 ... 나는 많은 예제를 검색했지만 정확한 해결책을 찾을 수 없습니다.

사실 난 ... 두 개의 탭에 대한 이미지의 유형 ... 같은 이미지이지만 두 개의 서로 다른 해상도

마지막으로

나는 아래 같은 XML 디자인을 설계 미세

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android"  
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
> 
<TabHost 
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="wrap_content" 
     android:layout_weight="1"> 
    </FrameLayout> 
    <TabWidget android:id="@android:id/tabs" 
     android:layout_width="fill_parent" android:layout_height="55dp" 

      /> 
</LinearLayout> 
</TabHost> 

<LinearLayout 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:layout_alignParentBottom="true" 
> 
<ImageView 
android:id="@+id/tab1"  
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_weight="1" 
android:visibility="invisible" 
android:background="@drawable/tab_mybars_on" 
/> 
<ImageView 
android:id="@+id/tab2"  
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_weight="1" 
android:visibility="invisible" 
android:background="@drawable/tab_mybeers_on" 
/>  
<ImageView 
android:id="@+id/tab3" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_weight="1" 
android:visibility="invisible" 
android:background="@drawable/tab_events_on" 
/>  
<ImageView 
android:id="@+id/tab4"  
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_weight="1" 
android:visibility="invisible" 
android:background="@drawable/tab_coupons_on" 
/>  
<ImageView 
android:id="@+id/tab5"  
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:layout_weight="1" 
android:visibility="invisible" 
android:background="@drawable/tab_brewedlife_on" 
/>  
</LinearLayout> 

</RelativeLayout> 

마지막으로 코드를했다 탭 활동의 : 잘 작동하는 경우

public class DownTabActivity extends TabActivity implements OnClickListener 
{ 
public static TabHost host; 
TabSpec spec; 
static int loadingcheck=0; 
public static String tabTag; 
ImageView tab[]=new ImageView[5]; 

public void onCreate(Bundle savedInstanceState) 
{ 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.tab); 

    spec= null; 
    host= getTabHost(); 
    host.setFocusable(false); 
//  host.getTabWidget().setDividerDrawable(R.drawable.tabbar_divider); 

    host.addTab(createTab("My Bars","MyBars",R.drawable.tab_mybars,MyBarsTabActivity.class)); 

    host.addTab(createTab("My Beers","MyBeers",R.drawable.tab_mybeers, MyBeersTabActivity.class)); 

    host.addTab(createTab("Events","Events",R.drawable.tab_myevents, MyEventsTabActivity.class)); 

    host.addTab(createTab("Coupons","Coupons",R.drawable.tab_coupons, CouponsTabActivity.class)); 

    host.addTab(createTab("Brewed Life","BrewedLife",R.drawable.tab_brewedlife, BrewedLifeTabActivity.class)); 

    host.setOnClickListener(this); 

    tab[0]=(ImageView)findViewById(R.id.tab1); 
    tab[1]=(ImageView)findViewById(R.id.tab2); 
    tab[2]=(ImageView)findViewById(R.id.tab3); 
    tab[3]=(ImageView)findViewById(R.id.tab4); 
    tab[4]=(ImageView)findViewById(R.id.tab5);  

    tabTag = host.getCurrentTabTag(); 
    Log.e("tab",tabTag); 

    tab[host.getCurrentTab()].setVisibility(View.VISIBLE); 


    host.setOnTabChangedListener(new TabHost.OnTabChangeListener() 
    { 
     public void onTabChanged(String arg0) 
     { 
      Log.e("tab argument is", arg0); 

      for(int i=0;i<5;i++){ 
      if(i==host.getCurrentTab()) tab[i].setVisibility(View.VISIBLE); 
      else tab[i].setVisibility(View.INVISIBLE); 
      } 
     }  
    }); 


} 

private TabSpec createTab(final String title, final String tag,final int drawable,final Class<?> intentClass) 
{ 
    final Intent intent = new Intent().setClass(this, intentClass); 

    final View tab = LayoutInflater.from(getTabHost().getContext()).inflate(R.layout.tab_indicator, null); 
    ((TextView)tab.findViewById(R.id.tab_text)).setText(""); 

    ((ImageView)tab.findViewById(R.id.tab_icon)).setBackgroundResource(drawable); 
    return getTabHost().newTabSpec(tag).setIndicator(tab).setContent(intent); 
} 

public void onClick(View v) 
{ 
    Log.v("on click Down tab", "on click Down tab"); 
} 
} 
+0

에서이 탭을 만들고 싶어 – Santosh

관련 문제