質問編集履歴
1
dialog部分を追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -13,3 +13,99 @@
|
|
13
13
|
|
14
14
|
|
15
15
|
どなたかヒントをくださいませんか。
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
・Javaのダイアログ部分です。ImageViewをタップでダイアログ表示させようと思っています
|
20
|
+
|
21
|
+
import android.app.AlertDialog;
|
22
|
+
|
23
|
+
import android.app.Dialog;
|
24
|
+
|
25
|
+
import android.content.DialogInterface;
|
26
|
+
|
27
|
+
import android.os.Bundle;
|
28
|
+
|
29
|
+
import android.widget.EditText;
|
30
|
+
|
31
|
+
import android.widget.Toast;
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
import androidx.fragment.app.DialogFragment;
|
36
|
+
|
37
|
+
import androidx.appcompat.app.AppCompatActivity;
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
import com.websarva.wings.android.todaysfeeling.MainActivity;
|
42
|
+
|
43
|
+
import com.websarva.wings.android.todaysfeeling.R;
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
public class OrderConfirmDialogFragment extends DialogFragment {
|
48
|
+
|
49
|
+
@Override
|
50
|
+
|
51
|
+
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
56
|
+
|
57
|
+
builder.setTitle(R.string.dialog_title);
|
58
|
+
|
59
|
+
builder.setMessage(R.string.dialog_msg);
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
final EditText editText = new EditText(getActivity());
|
64
|
+
|
65
|
+
builder.setView(editText);
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
builder.setPositiveButton("OK" , new DialogButtonClickListener());
|
70
|
+
|
71
|
+
builder.setNegativeButton("Back" , new DialogButtonClickListener());
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
AlertDialog dialog = builder.create();
|
76
|
+
|
77
|
+
return dialog;
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
private class DialogButtonClickListener implements DialogInterface.OnClickListener {
|
82
|
+
|
83
|
+
@Override
|
84
|
+
|
85
|
+
public void onClick(DialogInterface dialog , int which) {
|
86
|
+
|
87
|
+
String msg = "";
|
88
|
+
|
89
|
+
switch(which) {
|
90
|
+
|
91
|
+
case DialogInterface.BUTTON_POSITIVE:
|
92
|
+
|
93
|
+
msg = getString(R.string.dotst);
|
94
|
+
|
95
|
+
break;
|
96
|
+
|
97
|
+
case DialogInterface.BUTTON_NEGATIVE:
|
98
|
+
|
99
|
+
msg = getString(R.string.dofst);
|
100
|
+
|
101
|
+
break;
|
102
|
+
|
103
|
+
}
|
104
|
+
|
105
|
+
Toast.makeText(getActivity(), msg , Toast.LENGTH_LONG).show();
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
}
|