The class below is in a file Test.java and I want to call it from the function of public class Test.
Now i dont know how to access the function to show the alertdialog
. I mean how to access onCreateDialog(Bundle savedInstanceState)
of the class below , from another method?
the code below is copied from this source
class MyCustomDialog extends DialogFragment{
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
// Get the layout inflater
LayoutInflater inflater = getActivity().getLayoutInflater();
// Inflate and set the layout for the dialog
// Pass null as the parent view because its going in the dialog layout
builder.setView(inflater.inflate(R.layout.notification_list_layout, null))
// Add action buttons
.setPositiveButton("ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// sign in the user ...
}
})
.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
MyCustomDialog.this.getDialog().cancel();
}
});
return builder.create();
}
}
I want something like this