2011-12-20 4 views
0

Im new to android 그리고 난 tabhost와 간단한 응용 프로그램을 개발하려고합니다. 그리고 tabists가 내 모든 활동에 있어야합니다. 나는 5 개의 탭과 6 ~ 7 가지의 활동을 가지고 있으며, 이들 모두를 그 5 개의 탭에 표시하고 싶습니다.Tabview 모든 활동을 따르십시오

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


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

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

     /> 
</RelativeLayout> 

</TabHost> 

을 그리고 여기에 내가 탭 추가 : 여기

난 내 tabactivity을 만들

TabSpec tabSpec = mTabHost.newTabSpec("tab_test1"); 
    tabSpec.setIndicator("Map",res.getDrawable(R.drawable.world)); 
    Context ctx = this.getApplicationContext(); 
    Intent i = new Intent(ctx, DealFinderActivity.class); 
    tabSpec.setContent(i); 
    mTabHost.addTab(tabSpec); 

    mTabHost.getTabWidget().setBackgroundColor(Color.GRAY); 

    mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator 
      ("List Deals",res.getDrawable(R.drawable.database)) 
      .setContent(new Intent(this,ListDeals.class))); 

    //  TextView textView = (TextView) findViewById(R.id.textview3); 
    //  textView.setText("hello"); 
    mTabHost.addTab(mTabHost.newTabSpec("tab_test3").setIndicator("Favorites", 
      res.getDrawable(R.drawable.heart)).setContent(
        new Intent(this, ListDeals.class))); 

    mTabHost.addTab(mTabHost.newTabSpec("tab_test4").setIndicator("Settings", 
      res.getDrawable(R.drawable.preferences)).setContent(
        new Intent(this, DealDescription.class))); 

    mTabHost.addTab(mTabHost.newTabSpec("tab_test5").setIndicator("About", 
      res.getDrawable(R.drawable.newspaper)).setContent(
        new Intent(this, DealDescription.class))); 

그리고 난 새로운 활동에 변경이 사용하는 ListDeals.class의 :

 Intent myIntent = new Intent(getApplicationContext(), 
       DealMyAss.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 

     getApplication().startActivity(myIntent); 

하지만 여기에서는 탭뷰가 사라 집니까 ??

내가 어떻게 tabview를 유지할 수있는 아이디어? 사전

답변

0

ActivityGroup에서

덕분에 당신을 위해 무엇을 찾고 있습니다.

으로 이름을 지정하면 탭 내에서 여러 활동을 시도하게됩니다. 예제를 살펴보십시오. 하나는 here입니다.

모든 탭마다 하나의 활동 그룹을 만듭니다.

+0

ActivityGroups가 ICS에서 더 이상 사용되지 않도록 추가하고 싶습니다. 조각을 사용하는 것이 더 좋습니다. – Dante

+0

그래, 내가 그 예제를 따라 잘 작동하지만, 나는 클릭 가능한 오버레이가있는 Map 클래스를 가지고 있고, 그 오버레이는 MyItemizedOverlay에 있고 그 클래스에는 onTap 메서드가있어서 클래스를 변경할 수 없다. 그것은 변화 ?? 그것을 위해 android.app.application – Mustii1989

+0

나는이 다른 클래스, java.lang.ClassCastException가에서 변경하려는 오류 = 새로운 \t 보호 부울 onBalloonTap (INT 지수, OverlayItem 항목) { 의도 previewMessage을 의도 (c, DealDescription.class); TabGroupActivity parentActivity = (TabGroupActivity) c; parentActivity.startChildActivity ("ArrowsActivity", previewMessage); \t \t return true; – Mustii1989