For example, I have 5 tab inside a fragment tabhost.
For my past experience, if I have to implement a "go to detail" page inside a tab, I would just simply use activity to do (e.g. intent and create new activity).
Since I would like to keep the tabhost bar at the page so I can not use activity anymore , I need to change the fragment which is inside the tabhost. I tried using fragment transaction but when I switch tab the text is overlap, so how to change the fragment inside the tab? Thanks a lot.
This is how I create tabhost
tabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
tabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
tabHost.addTab(
tabHost.newTabSpec("home").setIndicator("",
getResources().getDrawable(R.drawable.btn_home)),
HomeFragment.class, null);
tabHost.addTab(
tabHost.newTabSpec("exhibit").setIndicator("",
getResources().getDrawable(R.drawable.btn_exhibit)),
ExhibitFragment.class, null);
tabHost.addTab(
tabHost.newTabSpec("plan").setIndicator("",
getResources().getDrawable(R.drawable.btn_floor_plan)),
PlanFragment.class, null);
tabHost.addTab(
tabHost.newTabSpec("collection").setIndicator("",
getResources().getDrawable(R.drawable.btn_collection)),
CollectionFragment.class, null);
tabHost.addTab(
tabHost.newTabSpec("setting").setIndicator("",
getResources().getDrawable(R.drawable.btn_setting)),
SettingFragment.class, null);
This is how I go to detail before, I would like to use fragment now
private OnClickListener set_listener(final int pos) {
OnClickListener listener = new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(ctx, CollectionDetail.class);
intent.putExtra("pos", pos);
startActivity(intent);
}
};
return listener;
}