I got 3 tabs however I got one fragment. Is it possible to use one fragment for the 3 tabs ?
Currently I have this in my FragmentPagerAdapter:
@Override
public Fragment getItem(int position) {
if (position == 0) {
return new FragmentTwo(region,"1");
} else if(position == 1){
return new FragmentTwo(region,"2");
}
return new FragmentTwo(region,"3");
}
But only showing all data in one tab..
I've edited my code but still getting all data in one tab. Currently :
@Override
public Fragment getItem(int position) {
return FragmentTwo.newInstance(region, position);
}
&&
static FragmentTwo newInstance(String region,int position) {
FragmentTwo frag=new FragmentTwo();
Bundle args=new Bundle();
args.putInt("KEY_POSITION", position);
args.putString("REGION", region);
if(position == 0){
args.putString("TYPE","A");
}
else if(position == 0){
args.putString("TYPE","B");
}
else{
args.putString("TYPE","C");
}
frag.setArguments(args);
return(frag);
}
For creating my FragmentPagerAdapter I am calling getSupportFragmentManager();