-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeleteSelectedDialogFragment.java
More file actions
48 lines (42 loc) · 1.72 KB
/
Copy pathdeleteSelectedDialogFragment.java
File metadata and controls
48 lines (42 loc) · 1.72 KB
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
package com.example.davidtruong.list;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
public class deleteSelectedDialogFragment extends DialogFragment{
//Make a dialogue and ask if the user wants to delete the selected rows
public interface deleteSelListener{
public void onDelSelPositiveClick(DialogFragment dialog);
public void onDelSelNegativeClick(DialogFragment dialog);
}
deleteSelListener mListener;
@Override
public Dialog onCreateDialog(Bundle savedInstance)
{
//Build the dialogFragment
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage("Delete selected rows?");
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
//When the yes button is pressed, call the corresponding function
mListener.onDelSelPositiveClick(deleteSelectedDialogFragment.this);
}
});
builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
//When the no button is pressed, call the corresponding function
mListener.onDelSelNegativeClick(deleteSelectedDialogFragment.this);
}
});
return builder.create();
}
@Override
public void onAttach(Context context)
{
super.onAttach(context);
//Maybe do a try-catch
mListener = (deleteSelListener) context;
}
}