How to execute action after DialogFragment positive button clicked

前端 未结 4 434
梦谈多话
梦谈多话 2020-12-30 12:19

I created the following DialogFragment deriving it from the Android documentation:

public class PayBillDialogFragment extends DialogFragment{

    @Ov         


        
4条回答
  •  时光说笑
    2020-12-30 12:45

    To call dialog you can use this:

    android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
    if (fm.findFragmentByTag("PayBillDialogFragment") == null) {
        PayBillDialogFragment payBillDialogFragment = new PayBillDialogFragment();
        payBillDialogFragment.show(fm, "PayBillDialogFragment");
    }
    

    In your dialogFragment,

    setPositiveButton("Paga", new DialogInterface.OnClickListener() {
       public void onClick(DialogInterface dialog, int id) {
           //Add your code here that should execute
           //when positive button is clicked
       }
    });
    

提交回复
热议问题