3 개의 탭이 있지만 하나의 조각이 있습니다. 3 개의 탭에 대해 하나의 조각을 사용할 수 있습니까? 여러 탭에 대해 동일한 조각 반환
현재 내 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");
}
그러나 하나 개의 탭에 모든 데이터를 보여주는 ..
내 코드를 편집하지만 여전히 하나 개의 탭에있는 모든 데이터를 가져 오는했습니다. 현재 :
@Override
public Fragment getItem(int position) {
return FragmentTwo.newInstance(region, position);
}
& &
내 FragmentPagerAdapter 내가에서 getSupportFragmentManager를 호출하고 생성을위한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);
}
();
당신은 모든 탭에 대해 동일한 조각 클래스를 사용하실 수 있습니다 :
는 관련이 게시물을 살펴보십시오. 여기에 내 샘플 중 하나가 있습니다 : https://github.com/commonsguy/cw-omnibus/tree/master/ViewPager/Fragments – CommonsWare나는 조각이 아니라 동일한 Fragment 클래스 인스턴스를 사용하는 방법이라고 생각합니다. 수업. – teamnorge