Android Open Source - isidore D C Confirm Dialog Fragment

From Project

Back to project page isidore.


The source code is released under:

GNU General Public License

If you think the Android project isidore listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.tbardici.isidore;
/*  ww w.  j av  a2 s.  c  o m*/
import android.content.DialogInterface;
import android.os.Bundle;

 * @author Teo
public class DCConfirmDialogFragment extends DialogFragment {

  private String default_message = "Are you sure you want to create this droplet?";
    /* The activity that creates an instance of this dialog fragment must
     * implement this interface in order to receive event callbacks.
     * Each method passes the DialogFragment in case the host needs to query it. */
    public interface NoticeDialogListener {
        public void onDialogPositiveClick(DialogFragment dialog);
        public void onDialogNegativeClick(DialogFragment dialog);
 // Use this instance of the interface to deliver action events
    NoticeDialogListener mListener;
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    Bundle args = this.getArguments();
    default_message += "\nHostname: " + args.getString("hostname");
    default_message += "\nSize: " + args.getString("type");
    default_message += "\nRegion: " + args.getString("region");
    default_message += "\nImage: " + args.getString("image");
    //use the Builder class for convenient dialog creation
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle("Create droplet");
    builder.setPositiveButton(R.string.yes, yesClick );
    builder.setNegativeButton(, noClick);
    return builder.create();
  public void onAttach(Activity activity) {
    // TODO Auto-generated method stub
        // Verify that the host activity implements the callback interface
        try {
            // Instantiate the NoticeDialogListener so we can send events to the host
            mListener = (NoticeDialogListener) activity;
        } catch (ClassCastException e) {
            // The activity doesn't implement the interface, throw exception
            throw new ClassCastException(activity.toString()
                    + " must implement NoticeDialogListener");
  private DialogInterface.OnClickListener yesClick = new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which) {
  private DialogInterface.OnClickListener noClick = new DialogInterface.OnClickListener() {
    public void onClick(DialogInterface dialog, int which) {


Java Source Code List