简体   繁体   English

viewpager不显示子viewpager

[英]viewpager not displaying child viewpager

in my class I'm calling another class to diplay fragment in dialog 在我的班级中,我正在调用另一个类来在对话框中显示片段

   public class FragmentT extends Fragment implements AnimationListener {
    ImageButton btn;
    Context cxt;

    RelativeLayout fragmentT;


        View vPOp;
        Animation animation;
         ViewPager pager;



    @Override
    public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
            Bundle savedInstanceState) {
        // TODO Auto-generated method stub

        if (container == null) {

            return null;
        }
        cxt=getActivity();
        this.activity=getActivity();
        vPOp = inflater.inflate(R.layout.pop, container, false);
        pager = (ViewPager) vPOp.findViewById(R.id.up);

        btn = (ImageButton) vPop.findViewById(R.id.button);



        btn.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub



                new DialogFragmentWindow().show(getSupportFragmentManager(),"");

            }
        });



        return vPop;
    }






    @Override
    public void onAnimationEnd(Animation arg0) {
        // TODO Auto-generated method stub

    }



    @Override
    public void onAnimationRepeat(Animation arg0) {
        // TODO Auto-generated method stub

    }



    @Override
    public void onAnimationStart(Animation arg0) {
        // TODO Auto-generated method stub

    }

}

where DialogFragmentWindow is DialogFragmentWindow所在的位置

public class DialogFragmentWindow extends DialogFragment {
    PageAdapter pPageAdapter;
    Context context;
    ViewPager vp;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.pop, container);
        context = getActivity();
    //  this.activity=getActivity();
         vp = (ViewPager) view.findViewById(R.id.pVF);

        List<Fragment> fragments = getFragments();
            FragmentAdapter pA = new FragmentAdapter(getChildFragmentManager(),fragments);

            vp.setAdapter(pA);

            getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);


        return view;
    }


    private List getFragments() {
        List<Fragment> fragmentPop = new Vector<Fragment>();
        //fragmentPop.add(FragSc1.newInstance());
        fragmentPop.add(Fragment.instantiate(context,
                FragSc1.class.getName()));
        fragmentPop.add(Fragment.instantiate(context,
                FragSc2.class.getName()));

        return fragmentPop;
    }



}

so the problem is,neither do DialogFragmentWindow is accepting the argument getChildFragmentManager(),nor do the FragmentT class is taking, 所以问题是,DialogFragmentWindow既不接受参数getChildFragmentManager(),也不接受FragmentT类,

new DialogFragmentWindow().show(getSupportFragmentManager(), "");

the viewpager i'm calling is in another layout so want to use getChildFragmentManager(),not able understand thwe prob,using chid fragment/viewpager for the first time. 我正在调用的viewpager是另一种布局,所以想要使用getChildFragmentManager(),第一次使用chid fragment / viewpager无法理解thwe prob。

Just try to do as like this. 试着像这样做。 It may help you. 它可能会帮助你。

new DialogFragmentWindow().show(getSupportFragmentManager().beginTransaction(), "dialog");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM