Show DialogFragment from another DialogFragment

前端 未结 9 736
春和景丽
春和景丽 2021-02-05 10:33

I have a DialogFragment that displays a list of options to the user, one of these options is \"Delete\" option, when the user presses the delete option I want to sh

9条回答
  •  粉色の甜心
    2021-02-05 11:17

    You can pass FragmentManage to newInstance() method of First DialogFragment then you can use it to show new dialogfragment this is my code.

    private static FragmentManager fragmentManager;
    
    public static PlayListDialog newInstance(Context context,  FragmentManager fragmentManager1) {
        playListDialog = new PlayListDialog();
        mContext = context;
        fragmentManager = fragmentManager1;
        return playListDialog;
    }
    
    @Override
    public void createNewPlaylist() {
        NewPlayListDialog newPlayListDialog = NewPlayListDialog.newInstance(mContext);
        newPlayListDialog.showDialog(fragmentManager.beginTransaction(),fragmentManager.findFragmentByTag("newdialog"));
    }
    

提交回复
热议问题