-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMainActivity.java
31 lines (25 loc) · 1.03 KB
/
MainActivity.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package com.lenovo.alertdemo;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new AlertDialog.Builder(this)
.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle("Are you Sure")
.setMessage("Do you definelty want to do this!!")
.setPositiveButton("Yes",new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(MainActivity.this,"It's Done",Toast.LENGTH_SHORT).show();
}
})
.setNegativeButton("No",null)
.show();
}
}