2012-08-23 8 views
0

자식 활동이 포함 된 세 개의 탭이 있습니다. 하나의 탭 중 하나를 클릭하면 주요 활동이 표시되지 않습니다. 다음 중 주요 활동을 어떻게 표시 할 수 있습니까? 3 개의 Tab 막대기 ... 누군가는 이것을위한 해결책이있다.? 미리안드로이드에서 탭을 클릭하면 주요 활동 시작

Thnx을 .. :)

Tabmain TabActivity

TabHost tabHost = getTabHost(); 
    TabSpec HomeSpec = tabHost.newTabSpec("Home"); 
    HomeSpec.setIndicator("Home", getResources().getDrawable(R.drawable.home)); 
    Intent HomeIntent = new Intent(this, HomeMediator.class); 
    HomeSpec.setContent(HomeIntent); 

    TabSpec SearchSpec = tabHost.newTabSpec("Search"); 
    SearchSpec.setIndicator("Search", getResources().getDrawable(R.drawable.search)); 
    Intent songsIntent = new Intent(this, SearchMediator.class); 
    SearchSpec.setContent(songsIntent); 

    TabSpec TreeInfoSpac = tabHost.newTabSpec("Tree Info"); 
    TreeInfoSpac.setIndicator("Botanical Name", getResources().getDrawable(R.drawable.carrot)); 
    Intent videosIntent = new Intent(this, BotaniacalMediator.class); 
    TreeInfoSpac.setContent(videosIntent); 

    tabHost.addTab(HomeSpec); 
    tabHost.addTab(SearchSpec); 
    tabHost.addTab(TreeInfoSpac); 
    tabHost.setOnTabChangedListener(new OnTabChangeListener() { 

     @Override 
     public void onTabChanged(String tabId) { 
      // TODO Auto-generated method stub 

     } 
    }); 

TabGroupActivity;

private ArrayList<String> mIdList; 

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    if (mIdList == null) { 
     mIdList = new ArrayList<String>(); 

    } 
} 


public void finishFromChild(Activity child) { 
    LocalActivityManager manager = getLocalActivityManager(); 
    int index = mIdList.size() - 1; 

    if (index < 0) { 
     finish(); 
     return; 
    } 

    manager.destroyActivity(mIdList.get(index), true); 
    Log.i("Activity Finish:", manager.getCurrentId()); 
    mIdList.remove(index); 
    index--; 
    String lastId = mIdList.get(index); 
    Intent lastIntent = manager.getActivity(lastId).getIntent(); 
    Window newWindow = manager.startActivity(lastId, lastIntent); 
    setContentView(newWindow.getDecorView()); 
} 

public void startChildActivity(String Id, Intent intent) { 

    Window window = getLocalActivityManager().startActivity(Id, 
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)); 
    if (window != null) { 
     mIdList.add(Id); 
     setContentView(window.getDecorView()); 
     Log.i("Activity Start:", getLocalActivityManager().getCurrentId()); 
    } 
} 

HomeMediator

public void onCreate(Bundle savedInstanceState) { 
    // TODO Auto-generated method stub 
    group = this; 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.mediator); 
    Intent LoginIntent = new Intent(HomeMediator.this, home.class); 
    startChildActivity("Home", LoginIntent); 

나는 정확히 지점을 모르지만 OnTabListener 시작 의도를 사용하는
@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.home); 
    parentActivity = (TabGroupActivity) getParent(); 
} 

public void btnInfo_Click(View v) { 
    Intent i = new Intent(getParent(), records.class); 
    i.putExtra("VAL", "BotanicalName"); 
    parentActivity.startChildActivity("Botanical", i); 
} 
+1

qtn을 사용중인 코드를 제공하십시오. 다소 모호합니다. –

답변

0

..

Intent main = new Intent (yourclass.this, MainClass.class); 
startActivity(main); 
0

당신 첫 번째 tabspec에서 다음과 같이 설정할 수 있습니다.

Intent HomeIntent = new Intent(this, MainClass.class); 
    HomeSpec.setContent(HomeIntent);