2

私のコード:

 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!

4

1 に答える 1

1

Android 4.2(およびAndroid Support Library rev 11)を使用していない限り、フラグメントはフラグメントでサポートされていません...

フラグメント内のフラグメント

于 2012-12-17T03:40:29.837 に答える