How to use Dialog Fragment? (showDialog deprecated) Android

后端 未结 4 1894
时光取名叫无心
时光取名叫无心 2020-11-28 13:08

I understand that there is this documentation

http://developer.android.com/reference/android/app/DialogFragment.html#AlertDialog

but as a new Android/Java le

4条回答
  •  悲哀的现实
    2020-11-28 13:50

    You can show the dialog like this:

    new AlertDialog.Builder(this)
    .setMessage("Are you sure you want to reset the count?")
    .setNegativeButton("No", new DialogInterface.OnClickListener() {    
    
        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            Toast.makeText(MainActivity.this, "Did not reset!", 5).show();
        }
    })
    .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            Toast.makeText(MainActivity.this, "Did Reset!", 5).show();
    
        }
    })
    .create().show();
    

提交回复
热议问题