Reputation: 185
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
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,
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.
Upvotes: 0
Views: 272
Reputation: 806
Just try to do as like this. It may help you.
new DialogFragmentWindow().show(getSupportFragmentManager().beginTransaction(), "dialog");
Upvotes: 2