我的代码:
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;
}
}
“mPager”始终为null。 任何人都可以提供一个例子吗? TKX!