-
Notifications
You must be signed in to change notification settings - Fork 0
/
editDialog.java
70 lines (56 loc) · 2.38 KB
/
editDialog.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package com.example.ya_.myapplication;
/*summber:https://github.com/itb-prd/membuat-aplikasi-android-dasar-yonasadiel*/
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Toast;
public class editDialog extends DialogFragment {
int mNum;
String mName;
static editDialog newInstance(int num, String name) {
editDialog f = new editDialog();
Bundle args = new Bundle();
args.putInt("num",num);
args.putString("name",name);
f.setArguments(args);
return f;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mNum = getArguments().getInt("num");
mName = getArguments().getString("name");
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new AlertDialog.Builder(getActivity())
.setMessage(Html.fromHtml("Apa yang ingin Anda lakukan dengan to do <b>'"+mName+"'</b> ?"))
.setPositiveButton("UBAH",new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent getNewNameIntent = new Intent(getActivity(), editScreen.class);
final int result = 1;
getNewNameIntent.putExtra("Index of ToDoList", mNum);
getNewNameIntent.putExtra("Name of ToDoList", mName);
getActivity().startActivityForResult(getNewNameIntent, result);
}
})
.setNegativeButton("HAPUS",new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent deleteIntent = new Intent(getActivity(), deleteScreen.class);
final int result = 3;
deleteIntent.putExtra("Index of ToDoList", mNum);
getActivity().startActivityForResult(deleteIntent, result);
}
})
.create();
}
}