How to get the Data from DialogFragment to MainActivity in Android?

前端 未结 4 603
自闭症患者
自闭症患者 2021-01-14 00:51

I create a application using DialogFragment.I want to get the Data from DialogFragment and setText in the MainActivity. I

4条回答
  •  粉色の甜心
    2021-01-14 01:23

    public void renameFile(){
    RenameFileDialog dialog = new RenameFileDialog();
            dialog.show(getSupportFragmentManager(), DIALOG_RENAME_FILE);
    

    }

      public void syncFolders(String value) {
     //some code
            new UpdateFolderAsyncTask().execute();
        }
    

    update listview with new updated value after performining operation in main activity class syncFolders() in DialogFragment class

       CustomDialogFragment extends DialogFragment{
    //some logic for performining operation
    String updatedValue=edittext.getText();
    
    MainActivity activity=(MainActivity)getActivity();
    activity.syncFolders(updatedValue);
    }
    

提交回复
热议问题