2011-10-25 6 views
1

세 가지 활동에 대한 탭을 만드는이 기본 탭 막대 레이아웃이 있습니다. 주요 활동 내에서 활동을 교환하고 싶다면 어떻게해야합니까?탭 막대 레이아웃 내의 활동 간 전환

기본 연락처 탭이있는 주소록 앱과 연락처를 클릭 할 때 자세한 활동이 필요합니다. 당신은 어떻게 TabHost로 활동을 대체 할 새로운 활동을 시작하는 요청하는 경우

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

      TabHost tabHost = getTabHost(); 

      // Tab for Photos 
     TabSpec photospec = tabHost.newTabSpec("Photos"); 
     // setting Title and Icon for the Tab 
     photospec.setIndicator("Photos", getResources().getDrawable(R.drawable.icon_photos_tab)); 
     Intent photosIntent = new Intent(this, PhotosActivity.class); 
     photospec.setContent(photosIntent); 

     // Tab for Songs 
     TabSpec songspec = tabHost.newTabSpec("Songs"); 
     songspec.setIndicator("Songs", getResources().getDrawable(R.drawable.icon_songs_tab)); 
     Intent songsIntent = new Intent(this, SongsActivity.class); 
     songspec.setContent(songsIntent); 

     // Tab for Videos 
     TabSpec videospec = tabHost.newTabSpec("Videos"); 
     videospec.setIndicator("Videos", getResources().getDrawable(R.drawable.icon_videos_tab)); 
     Intent videosIntent = new Intent(this, VideosActivity.class); 
     videospec.setContent(videosIntent); 

     // Adding all TabSpec to TabHost 
     tabHost.addTab(photospec); // Adding photos tab 
     tabHost.addTab(songspec); // Adding songs tab 
     tabHost.addTab(videospec); // Adding videos tab 

    }* 
+0

탭 항목을 클릭하면 탭 안의 탭처럼 보이시겠습니까? –

답변

1

, 그럼 난 당신이 반면에

Intent intent = new Intent(this, NewActivity.class); 
startActivity(intent); 

정상적으로이 새로운 활동을 시작할 것이라고 믿는다 , 탭 내에서 활동을 변경하는 방법에 대해 질문하는 경우 this thread은 원하는 것처럼 보입니다.

+0

링크에 예제를 구현하는 방법에 대해 잘 모릅니다. 완전하지 않니? – Adam