my code:
public class CustomDialogFragment extends SherlockDialogFragment {
/** The system calls this to get the DialogFragment's layout, regardless
of whether it's being displayed as a dialog or an embedded fragment. */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.p_product_gallery, container, false);
ImageView tttiv=(ImageView)v.findViewById(R.id.test_image);
tttiv.setImageResource(R.drawable.baozi);
return v;
}
/** The system calls this only when creating the layout in a dialog. */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// The only reason you might override this method when using onCreateView() is
// to modify any dialog characteristics. For example, the dialog includes a
// title by default, but your custom layout might not need it. So here you can
// remove the dialog title, but you must call the superclass to get the Dialog.
mDialog = super.onCreateDialog(savedInstanceState);
mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
mDialog.getWindow().setBackgroundDrawable((new ColorDrawable(0x0f000000)));
mPager = (ViewPager) mDialog.findViewById(R.id.aa_pager);
mPager.setAdapter(mAdapter);
mAdapter = new ProductGalleryAdapter(getSupportFragmentManager());
return mDialog;
}
}
The “mPager” always is null.
Can any one provide an example?
tkx!
Unless you are using Android 4.2 (and Android Support Library rev 11), fragments are not supported in fragments…
Fragments within Fragments