FragmentPagerAdapter에로드 할 부분을 처리하기위한 클래스 class가 있습니다. 지금은 조각을 잘로드하지만 지금은 FragmentActivity를 구현하고 싶습니다. 그리고 활동 유형에 따라 "newinstance"를 사용할 수 없기 때문에 문제를 만드는 방법을 생각하고 있습니다. 그 위에는 어떻게 해야할지 모릅니다. 그 FragmentActivity를 "newinstance"메소드를 통해 Fragment를로드하는 것과 다른 것으로서 호출한다. 두 번째 탭은 FragmentActivity로 확장하고자하는 탭입니다. FragmentPagerAdapter에 FragmentActivity를 어떻게 구현합니까?
FragmentTransaction ft = fm.beginTransaction();
ft.add(R.id.fragment_content, new BasicFragment());
ft.commit();
사람이 올바른 방향으로 날 지점 도움이 될 수 있습니다
:public class SectionsPagerAdapter extends FragmentPagerAdapter {
private Context _context;
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
_context= getApplicationContext();
}
@Override
public Fragment getItem(int i) {
Fragment f = new Fragment();
switch(i){
case 0:
f=News.newInstance(_context);
break;
case 1:
f=Info.newInstance(_context);
break;
case 2:
f=Files.newInstance(_context);
break;
case 3:
f=Donate.newInstance(_context);
break;
}
/*
Fragment fragment = new DummySectionFragment();
Bundle args = new Bundle();
args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, i + 1);
fragment.setArguments(args);
*/
return f;
}
@Override
public int getCount() {
return 4;
}
@Override
public CharSequence getPageTitle(int position) {
switch (position) {
case 0: return getString(R.string.title_section1).toUpperCase();
case 1: return getString(R.string.title_section2).toUpperCase();
case 2: return getString(R.string.title_section3).toUpperCase();
case 3: return getString(R.string.title_section4).toUpperCase();
}
return null;
}
}
내 생각 엔 난 단지 스위칭 조각에 대한 것과의 getItem 방법을 사용하지 못할 것을 내가 뭔가를 사용해야 할 것입니까?
동의합니다. FragmentActivity를 Fragment로 변환해야한다고 생각합니다. – conor
하지만 액티비티는 FragmentActivity가되어야합니다. FragmentActivity – user1811306
@ user1811306으로 확장하면 가능합니다. ViewPager에 액티비티를 넣을 수 없습니다. * ViewPager를 포함하는 액티비티는'FragmentActivity' 일 수 있으며'ViewPager'가 프래그먼트를 포함한다면'FragmentActivity' 일 필요가 있습니다. – CommonsWare