탭과 함께 이중 창 조각이있는 해결책을 찾기 위해 여러 날을 지낸 후에 필자는 포기하고 자신의 목록보기를 만들었습니다. 내 탭을 관리하십시오. 모든 코드는 탭에서 이전 조각을 제거하고 목록에서 클릭 한 항목을 기반으로 새 조각을 만들려고하는 한 부분을 제외하고 모두 작동합니다. 여기조각이 제거되지 않았습니다
는 탭의 조각이 생성되는 곳이다 :
내가리스트 뷰 클릭에서 조각을 추가public class AppSectionsPagerAdapter extends FragmentPagerAdapter {
public AppSectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
//THESE FRAGMENTS ARE GENERATED WITH TABS AT START
@Override
public Fragment getItem(int i) {
switch (i) {
case 0:
return new DescriptionFragment();
case 1:
return new ImagesFragment();
default:
return new DescriptionFragment();
}
}
:
public void addfragment() {
//THIS FRAGMENT GOES ON TOP AFTER LISTVIEW CLICK
kick_activity.this.getSupportFragmentManager().popBackStack();
DescriptionFragment fragment = new DescriptionFragment();
android.support.v4.app.FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.container, fragment);
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
ft.commit();
}
내 DescriptionFragment 조각 :
public static class DescriptionFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_section_description, container, false);
text = ((TextView) rootView.findViewById(R.id.description));
text.setText(Html.fromHtml(description_text));
return rootView;
}
I 내가 뭘 잘못하고 있는지, 그냥 어떻게 고쳐야할지 모르겠다. 그것은 getItem()에서 단편이 만들어지고 내 listview를 클릭하고 addfragment()가 호출 될 때 링크되지 않은 단편으로 인해 오버레이 된 것처럼 보입니다. 내 모든 조각이 연결되어 오버레이되지 않도록 'return new DescriptionFragment'대신 'case 0'에 무엇을 넣을 수 있습니까?
주 -. 내가 시도하고) (의 getItem에서 응용 프로그램 충돌을 ft.repalce를 사용하여 로그 캣에 따라 때, 그것은 R.id.container을 찾을 수없는, 그래서 난 단지에 그 코드를 이동할 수 없습니다
감사합니다 당신의 도움을 위해 사전에, 나는 꽤 며칠 동안이 일에 매달려 있기 때문에 어떤 해결책을 주셔서 감사하겠습니다.
정말 고마워요! –