What I am doing:
- I have a
fragmentabhost
in a fragment that has3-tabs
in it. - On click of tabs i am able to change the fragments dynamically
On click
of first tab i am displayingRatingAscending.class
What I am trying to do:
- Now
Onclick
of the same tab I want to displayRatingDescending.class
Note: in the onResume()
I am able to detect click event
for the firsttab
Now how can I change the tab to RatingDescending.class
from RatingAscending.class
when I click the tab for the second time
Fragment1.java
public class Fragment1 extends SherlockFragment{
private FragmentTabHost mTabHost;
private static int count=0;
//Mandatory Constructor
public Fragment1() {
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment1,container, false);
mTabHost = (FragmentTabHost)rootView.findViewById(android.R.id.tabhost);
mTabHost.setup(getActivity(), getChildFragmentManager(), R.id.realtabcontent);
mTabHost.addTab(mTabHost.newTabSpec("fragmentb").setIndicator("Rating"),
RatingAscending.class, null);
mTabHost.addTab(mTabHost.newTabSpec("fragmentc").setIndicator("Price"),
PriceAscending.class, null);
mTabHost.addTab(mTabHost.newTabSpec("fragmentd").setIndicator("Distance"),
DistanceAscending.class, null);
return rootView;
}
@Override
public void onResume() {
// TODO Auto-generated method stub
super.onResume();
mTabHost.getTabWidget().getChildAt(0).setOnClickListener(new OnClickListener() {
public void onClick(View v) {
count++;
Log.d("You clicked ", count+"time");
}
});
}
}