How can I pass data from activity to the dialogFragment that activity invoked?

后端 未结 3 1857
臣服心动
臣服心动 2021-02-05 11:58

In my application I have a form the user fills in. Pressing \"save\" the data will be saved to the local database. I want to add a confirm dialog for the user to review the deta

3条回答
  •  一整个雨季
    2021-02-05 12:16

    In your Activity

    ImageViewDialogFragment dialogFragment = new ImageViewDialogFragment ();
                            Bundle bundle = new Bundle();
                            bundle.putString("link",moviesList.get(position).getImage());
                            dialogFragment.setArguments(bundle);
                            dialogFragment.show((GalleryReviewActivity.this).getSupportFragmentManager(),"Image Dialog");
    

    in your DialogFragment

     Bundle bundle = getArguments();
     String imageLink = bundle.getString("link","");
    

提交回复
热议问题