Example usage for android.app AlertDialog.Builder setCancelable

List of usage examples for android.app AlertDialog.Builder setCancelable

Introduction

In this page you can find the example usage for android.app AlertDialog.Builder setCancelable.

Prototype

public void setCancelable(boolean flag) 

Source Link

Document

Sets whether this dialog is cancelable with the KeyEvent#KEYCODE_BACK BACK key.

Usage

From source file:com.radicaldynamic.groupinform.activities.LauncherActivity.java

public Dialog onCreateDialog(int id) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    Dialog dialog = null;/*from  w  w  w . j  ava 2s.  co m*/

    if (isFinishing()) {
        return dialog;
    }

    switch (id) {
    case DIALOG_COUCH_ERROR:
        builder.setMessage("Error Initializing or Starting Database")
                .setPositiveButton("Try Again?", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        startCouch();
                    }
                }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        LauncherActivity.this.moveTaskToBack(true);
                    }
                });

        dialog = builder.create();
        break;

    case DIALOG_EXPIRED:
        builder.setCancelable(false).setIcon(R.drawable.ic_dialog_alert).setTitle("Subscription Expired")
                .setMessage(
                        "The subscription for this device profile has expired.\n\nPlease see your account owner to have the subscription renewed or this profile transferred to an active subscription or email our support team at\n\nsupport@groupcomplete.com");

        builder.setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                exitApplication();
            }
        });

        dialog = builder.create();
        break;

    case DIALOG_EXPIRED_CANNOT_CONNECT:
        builder.setCancelable(false).setIcon(R.drawable.ic_dialog_alert).setTitle("Subscription Expired")
                .setMessage(
                        "The subscription for this device profile has expired.\n\nPlease see your account owner to have the subscription renewed or this profile transferred to an active subscription or email our support team at\n\nsupport@groupcomplete.com\n\nPlease note that the Group Complete service could not be contacted so this message may not reflect up-to-date changes to your Group Complete account.  Please ensure that this device can access the Internet and restart GC Mobile.");

        builder.setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                exitApplication();
            }
        });

        dialog = builder.create();
        break;

    case DIALOG_EXTERNAL_STORAGE_UNAVAILABLE:
        builder.setCancelable(false).setIcon(R.drawable.ic_dialog_alert)
                .setMessage(getString(R.string.no_sd_error));

        builder.setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                finish();
            }
        });

        dialog = builder.create();
        break;

    // Registered    
    case DIALOG_UNABLE_TO_CONNECT_OFFLINE_DISABLED:
        String msg;

        if (Collect.getInstance().getInformOnlineState().hasReplicatedFolders())
            msg = getString(R.string.tf_connection_error_registered_with_db_msg);
        else
            msg = getString(R.string.tf_connection_error_registered_without_db_msg);

        builder.setCancelable(false).setIcon(R.drawable.ic_dialog_alert).setTitle(R.string.tf_unable_to_connect)
                .setMessage(msg);

        builder.setPositiveButton(getText(R.string.tf_retry), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                restartActivity(true);
            }
        });

        if (Collect.getInstance().getInformOnlineState().hasReplicatedFolders()) {
            builder.setNeutralButton(getText(R.string.tf_go_offline), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    startCouch();
                }
            });
        }

        builder.setNegativeButton(getText(R.string.tf_exit_inform), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                finish();
            }
        });

        dialog = builder.create();
        break;

    // Registered
    case DIALOG_UNABLE_TO_CONNECT_OFFLINE_ENABLED:
        builder.setCancelable(false).setIcon(R.drawable.ic_dialog_info)
                .setTitle(R.string.tf_offline_mode_enabled)
                .setMessage(getString(R.string.tf_offline_mode_enabled_msg));

        builder.setPositiveButton(getText(R.string.tf_continue), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                startCouch();
            }
        });

        dialog = builder.create();
        break;

    case DIALOG_UNABLE_TO_REGISTER:
        builder.setCancelable(false).setIcon(R.drawable.ic_dialog_alert).setTitle(R.string.tf_unable_to_connect)
                .setMessage(getString(R.string.tf_connection_error_unregistered_msg));

        builder.setPositiveButton(getText(R.string.tf_retry), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                restartActivity(true);
            }
        });

        builder.setNegativeButton(getText(R.string.tf_exit_inform), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                finish();
            }
        });

        dialog = builder.create();
        break;

    case DIALOG_UPGRADE_FAILED:
        builder.setMessage("Error Upgrading Application")
                .setPositiveButton("Try Again?", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        restartActivity(true);
                    }
                }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        LauncherActivity.this.moveTaskToBack(true);
                    }
                });

        dialog = builder.create();
        break;
    }

    return dialog;
}

From source file:com.mylikes.likes.etchasketch.Slate.java

public void promptForText(final int x, final int y, final TextDrawing drawing) {
    LayoutInflater li = LayoutInflater.from(getContext());
    View promptsView = li.inflate(R.layout.prompts, null);
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getContext());

    // set prompts.xml to alertdialog builder
    alertDialogBuilder.setView(promptsView);

    final EditText userInput = (EditText) promptsView.findViewById(R.id.editTextDialogUserInput);
    if (drawing != null) {
        String text = drawing.getText();
        userInput.setText(text);//from   w  ww .  j  ava 2s  . com
        userInput.setSelection(text.length());
    }

    // TODO: add font dropdown to dialog
    alertDialogBuilder.setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            if (drawing != null) {
                drawing.setText(userInput.getText().toString());
                invalidate();
            } else {
                addText(x, y, userInput.getText().toString());
            }
        }
    }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });

    alertDialogBuilder.create().show();
}

From source file:cgeo.geocaching.cgeocaches.java

public void removeFromHistoryCheck() {
    AlertDialog.Builder dialog = new AlertDialog.Builder(this);
    dialog.setCancelable(true);//from  www .j  av a 2  s  . c  o m
    dialog.setTitle(res.getString(R.string.caches_removing_from_history));
    dialog.setMessage((adapter != null && adapter.getCheckedCount() > 0)
            ? res.getString(R.string.cache_remove_from_history)
            : res.getString(R.string.cache_clear_history));
    dialog.setPositiveButton(getString(android.R.string.yes), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            removeFromHistory();
            dialog.cancel();
        }
    });
    dialog.setNegativeButton(getString(android.R.string.no), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });

    AlertDialog alert = dialog.create();
    alert.show();
}

From source file:cgeo.geocaching.cgeocaches.java

public void dropStored(final boolean removeListAfterwards) {
    AlertDialog.Builder dialog = new AlertDialog.Builder(this);
    dialog.setCancelable(true);
    dialog.setTitle(res.getString(R.string.caches_drop_stored));

    if (adapter.getCheckedCount() > 0) {
        dialog.setMessage(res.getString(R.string.caches_drop_selected_ask));
    } else {/*from w  w w.j  a v  a  2 s .com*/
        dialog.setMessage(res.getString(R.string.caches_drop_all_ask));
    }
    dialog.setPositiveButton(getString(android.R.string.yes), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {
            dropSelected(removeListAfterwards);
            dialog.cancel();
        }
    });
    dialog.setNegativeButton(getString(android.R.string.no), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });

    AlertDialog alert = dialog.create();
    alert.show();
}

From source file:ch.uzh.supersede.feedbacklibrary.AnnotateImageActivity.java

private void showStickerDialog() {
    if (stickerDialog == null) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setIcon(R.drawable.ic_sentiment_satisfied_black_48dp);
        builder.setTitle(getResources().getString(R.string.supersede_feedbacklibrary_sticker_dialog_title));
        builder.setNegativeButton(getResources().getString(R.string.supersede_feedbacklibrary_cancel_string),
                new DialogInterface.OnClickListener() {
                    @Override// w w  w .j  a va2s  . co m
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
        if (stickerArrayAdapter == null) {
            stickerArrayAdapter = new StickerArrayAdapter(builder.getContext(), stickerIcons, stickerLabels);
        }
        builder.setAdapter(stickerArrayAdapter, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                addSticker(stickerArrayAdapter.getIcons().get(which));
            }
        });
        builder.setCancelable(false);
        stickerDialog = builder.create();
    }
    stickerDialog.show();
}

From source file:com.e2g.ecocicle.barcode.IntentIntegrator.java

private AlertDialog showDownloadDialog() {
    AlertDialog.Builder downloadDialog = new AlertDialog.Builder(activity);
    downloadDialog.setTitle(title);//from w w w. ja  va2  s.  co  m
    downloadDialog.setMessage(message);
    downloadDialog.setPositiveButton(buttonYes, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            String packageName;
            if (targetApplications.contains(BS_PACKAGE)) {
                // Prefer to suggest download of BS if it's anywhere in the list
                packageName = BS_PACKAGE;
            } else {
                // Otherwise, first option:
                packageName = targetApplications.get(0);
            }
            Uri uri = Uri.parse("market://details?id=" + packageName);
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            try {
                if (fragment == null) {
                    activity.startActivity(intent);
                } else {
                    fragment.startActivity(intent);
                }
            } catch (ActivityNotFoundException anfe) {
                // Hmm, market is not installed
                Log.w(TAG, "Google Play is not installed; cannot install " + packageName);
            }
        }
    });
    downloadDialog.setNegativeButton(buttonNo, null);
    downloadDialog.setCancelable(true);
    return downloadDialog.show();
}

From source file:com.gsma.rcs.ri.messaging.GroupTalkView.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    try {//www.  j  av a 2s. c o m
        switch (item.getItemId()) {
        case R.id.menu_insert_smiley:
            AlertDialog alert = Smileys.showSmileyDialog(this, mComposeText, getResources(),
                    getString(R.string.menu_insert_smiley));
            registerDialog(alert);
            break;

        case R.id.menu_participants:
            alert = Utils.showList(this, getString(R.string.menu_participants),
                    getSetOfParticipants(mGroupChat.getParticipants()));
            registerDialog(alert);
            break;

        case R.id.menu_add_participant:
            addParticipants();
            break;

        case R.id.menu_quicktext:
            addQuickText();
            break;

        case R.id.menu_send_file:
            SendGroupFile.startActivity(this, mChatId);
            break;

        case R.id.menu_send_geoloc:
            getGeoLoc();
            break;

        case R.id.menu_showus_map:
            DisplayGeoloc.showContactsOnMap(this, mGroupChat.getParticipants().keySet());
            break;

        case R.id.menu_close_session:
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle(R.string.title_chat_exit);
            builder.setPositiveButton(R.string.label_ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    if (mGroupChat != null) {
                        try {
                            mGroupChat.leave();
                        } catch (RcsServiceException e) {
                            showExceptionThenExit(e);
                        }
                    }
                    GroupTalkView.this.finish();
                }
            });
            builder.setNegativeButton(R.string.label_cancel, null);
            builder.setCancelable(true);
            registerDialog(builder.show());
            break;
        }

    } catch (RcsServiceException e) {
        showException(e);
    }
    return true;
}

From source file:com.suyonoion.easyviewpagerui.ExpandedViewpagerUI.java

public ExpandedViewpagerUI(Context context, AttributeSet attrs) {
    super(context, attrs);

    List<String> mengisi_Tempat_judul = new ArrayList<>();
    final List<String> kodestringsxml_str = new ArrayList<>();
    final List<String> kodeutama_str = new ArrayList<>();

    for (int i = 1; i <= Jumlah_Page; i++) {
        try {/* w  w  w  . j  av  a 2s.  co  m*/
            mengisi_Tempat_judul.add(getResources().getString(setResource("judul_halaman_" + i, "string")));
        }

        catch (Throwable e) {

            if (Jumlah_Page > 25) {
                mengisi_Tempat_judul.add("Judul " + i + " belum ditambahkan di strings.xml");
                AlertDialog.Builder b = new AlertDialog.Builder(getContext());
                final String st = "<LinearLayout android:background=\"@drawable/a3\" android:id=\"@+id/id_halaman_4\" android:layout_width=\"match_parent\" android:layout_height=\"match_parent\" android:orientation=\"vertical\" android:gravity=\"center\">\n"
                        + "<TextView android:textSize=\"70sp\" android:layout_gravity=\"center\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:text=\"3\" android:textColor=\"#ff473eff\"/>\n"
                        + "</LinearLayout>";

                b.setMessage(
                        "Berbahaya Jumlah_Page terlalu banyak lebih dari 25 pages, penambahan kode utama tidak akan ditampilkan...!! Dan"
                                + "Kodeutama->strings.xml->smali belum sinkron (tidak sama). Mengedit 0x3 saja tidak cukup, anda juga perlu mengedit kodeutama dan strings.xml, agar sama. \n \n"
                                + "Jika anda telah mengubah/mengedit/menambah/menghapus Jumlah_Page = 3 (0x3) menjadi Jumlah_Page = "
                                + Jumlah_Page
                                + ", kodeutama, dan strings.xml maka, \n \n Tolong cek dan edit kembali kode utama di expanded anda dan strings.xml di value , sesuaikan dengan jumlah page yaitu "
                                + Jumlah_Page
                                + " dalam smali. dan tambahkan ini sejumlah pages yang anda mau :\n \n" + st
                                + "\n\n" + "sesuaikan dengan id_halaman");
                b.setCancelable(true);
                b.setNeutralButton("Copy to Clipboard", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        if (sdk < android.os.Build.VERSION_CODES.HONEYCOMB) {
                            android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getContext()
                                    .getSystemService(Context.CLIPBOARD_SERVICE);
                            clipboard.setText(st);
                            Toast.makeText(getContext(), "Text Telah Ter-Copy ke Clipboard", Toast.LENGTH_SHORT)
                                    .show();
                        } else {
                            android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getContext()
                                    .getSystemService(Context.CLIPBOARD_SERVICE);
                            android.content.ClipData clip = android.content.ClipData.newPlainText("Clip", st);
                            Toast.makeText(getContext(), "Text Telah Ter-Copy ke Clipboard", Toast.LENGTH_SHORT)
                                    .show();
                            clipboard.setPrimaryClip(clip);
                        }
                        dialog.dismiss();
                    }
                });
                b.setTitle("Pesan Saya...!!!");
                AlertDialog ad = b.create();
                ad.show();
            } else {
                mengisi_Tempat_judul.add("Judul " + i + " belum ditambahkan di strings.xml");
                AlertDialog.Builder b = new AlertDialog.Builder(getContext());
                kodeutama_str.add(
                        "<LinearLayout android:background=\"@drawable/a3\" android:id=\"@+id/id_halaman_" + i
                                + "\" android:layout_width=\"match_parent\" android:layout_height=\"match_parent\" android:orientation=\"vertical\" android:gravity=\"center\">\n"
                                + " <TextView android:textSize=\"70sp\" android:layout_gravity=\"center\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:text=\""
                                + i + "\" android:textColor=\"#ff473eff\"/>\n" + "</LinearLayout> \n \n");

                b.setMessage(
                        "Kodeutama->strings.xml->smali belum sinkron (tidak sama). Mengedit 0x3 saja tidak cukup, anda juga perlu mengedit kodeutama dan strings.xml, agar sama. \n \n"
                                + "Jika anda telah mengubah/mengedit/menambah/menghapus Jumlah_Page = 3 (0x3) menjadi Jumlah_Page = "
                                + Jumlah_Page
                                + ", kodeutama, dan strings.xml maka, \n \n Tolong cek dan edit kembali kode utama di expanded anda dan strings.xml di value , sesuaikan dengan jumlah page yaitu "
                                + Jumlah_Page
                                + " dalam smali atau perhatikan kode utama dibawah ini silahkan dicontek dan tambahkan ke expanded:\n \n"
                                + kodeutama_str + "\n \n"
                                + "Copy to Clipboard dan oh iyah Hapus koma(,) kurung buka dan tutup [ ] yah :)");
                b.setCancelable(true);
                b.setNeutralButton("Copy to Clipboard", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        if (sdk < android.os.Build.VERSION_CODES.HONEYCOMB) {
                            android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getContext()
                                    .getSystemService(Context.CLIPBOARD_SERVICE);
                            clipboard.setText(kodeutama_str.toString());
                            Toast.makeText(getContext(), "Text Telah Ter-Copy ke Clipboard", Toast.LENGTH_SHORT)
                                    .show();
                        } else {
                            android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getContext()
                                    .getSystemService(Context.CLIPBOARD_SERVICE);
                            android.content.ClipData clip = android.content.ClipData.newPlainText("Clip",
                                    kodeutama_str.toString());
                            Toast.makeText(getContext(), "Text Telah Ter-Copy ke Clipboard", Toast.LENGTH_SHORT)
                                    .show();
                            clipboard.setPrimaryClip(clip);
                        }
                        dialog.dismiss();
                    }
                });
                b.setTitle("Pesan Saya...!!!");
                AlertDialog ad = b.create();
                ad.show();
            }

        }
    }

    AdapterExpandedViewpagerUI adapter = new AdapterExpandedViewpagerUI(mengisi_Tempat_judul);
    final ViewPager EasyExpandedViewPagerUI = (ViewPager) this.findViewById(setResource("id_viewpager", "id"));
    EasyExpandedViewPagerUI.setPageTransformer(true, new CubeOutTransformer());
    EasyExpandedViewPagerUI.setAdapter(adapter);
    EasyExpandedViewPagerUI.setOffscreenPageLimit(Jumlah_Page);
    if (EasyExpandedViewPagerUI.getWidth() > 0) {
        Bitmap image = JadikanBlur.blur(EasyExpandedViewPagerUI);
        EasyExpandedViewPagerUI.setBackgroundDrawable(new BitmapDrawable(getContext().getResources(), image));
    } else {
        EasyExpandedViewPagerUI.getViewTreeObserver()
                .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                    @Override
                    public void onGlobalLayout() {
                        Bitmap image = JadikanBlur.blur(EasyExpandedViewPagerUI);
                        EasyExpandedViewPagerUI
                                .setBackgroundDrawable(new BitmapDrawable(getContext().getResources(), image));
                    }
                });
    }

    adapter.notifyDataSetChanged();
}

From source file:com.xrmaddness.offthegrid.ListActivity.java

void warn_settings_dialog() {
    LayoutInflater factory = LayoutInflater.from(this);

    final View textEntryView = factory.inflate(R.layout.gmail_account, null);

    final EditText input_name = (EditText) textEntryView.findViewById(R.id.gmail_name);
    final EditText input_address = (EditText) textEntryView.findViewById(R.id.gmail_address);
    final EditText input_pass = (EditText) textEntryView.findViewById(R.id.gmail_pass);

    input_name.setText("", TextView.BufferType.EDITABLE);
    input_address.setText("", TextView.BufferType.EDITABLE);
    input_pass.setText("", TextView.BufferType.EDITABLE);

    AlertDialog.Builder alert = new AlertDialog.Builder(this);

    alert.setTitle(R.string.action_warn_settings);
    alert.setMessage(getString(R.string.dialog_warn_settings));
    alert.setView(textEntryView);//from   w  w w .ja  v a2  s.  c  om
    alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            String name = input_name.getText().toString();
            String address = input_address.getText().toString();
            String pass = input_pass.getText().toString();
            if (name.length() <= 0 || address.length() <= 0 || pass.length() <= 0) {
                return;
            }

            settings_set_gmail(name, address, pass);
        }
    });
    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
        }
    });
    alert.setCancelable(true);
    alert.show();
}

From source file:com.ezac.gliderlogs.FlightDetailActivity.java

@Override
protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    setContentView(R.layout.start_edit);
    // get references to our objects
    mDateText = (EditText) findViewById(R.id.flight_date);
    mRegiSpin = (Spinner) findViewById(R.id.flight_registration);
    mPilotSpin = (Spinner) findViewById(R.id.flight_pilot);
    mInstChck = (CheckBox) findViewById(R.id.flight_instruction);
    mCoPilotSpin = (Spinner) findViewById(R.id.flight_copilot);
    mStartText = (EditText) findViewById(R.id.flight_start);
    mLandText = (EditText) findViewById(R.id.flight_landing);
    mDuraText = (EditText) findViewById(R.id.flight_duration);
    // disable input, these are output only
    mDateText.setClickable(false);//from w ww . java 2  s .  co  m
    mDateText.setFocusable(false);
    mStartText.setClickable(false);
    mStartText.setFocusable(false);
    mLandText.setClickable(false);
    mLandText.setFocusable(false);
    mDuraText.setClickable(false);
    mDuraText.setFocusable(false);
    mBodyText = (EditText) findViewById(R.id.flight_edit_notes);
    mDateText.setText(FlightOverviewActivity.ToDay);
    mTypeNorm = (CheckBox) findViewById(R.id.flight_type_norm);
    mTypePass = (CheckBox) findViewById(R.id.flight_type_pass);
    mTypeDona = (CheckBox) findViewById(R.id.flight_type_dona);
    mTypeClub = (CheckBox) findViewById(R.id.flight_type_club);

    mLaunchWinch = (CheckBox) findViewById(R.id.flight_launch_winch);
    mLaunchTow = (CheckBox) findViewById(R.id.flight_launch_tow);
    mLaunchMotor = (CheckBox) findViewById(R.id.flight_launch_motor);

    Button confirmButton = (Button) findViewById(R.id.flight_edit_button);
    Button exitButton = (Button) findViewById(R.id.flight_quit_button);
    Button againButton = (Button) findViewById(R.id.flight_again_button);
    Button timeSButton = (Button) findViewById(R.id.btnChangeSTime);
    Button timeLButton = (Button) findViewById(R.id.btnChangeLTime);
    Button clearSButton = (Button) findViewById(R.id.btnClearSTime);
    Button clearLButton = (Button) findViewById(R.id.btnClearLTime);
    Button gliderButton = (Button) findViewById(R.id.btn_ext_1);
    Button pilotButton = (Button) findViewById(R.id.btn_ext_2);
    Bundle extras = getIntent().getExtras();

    // get data from DB tables and load our glider/member list
    addItemSpinner1();
    addItemSpinner2();
    // only now check if these are still empty
    if (GliderList.isEmpty() || MemberList.isEmpty()) {
        makeToast("Opties -> Voer eerst de actie 'Dag opstarten' uit, mogelijk was er een netwerk probleem !.");
        setResult(RESULT_CANCELED);
        finish();
    }
    // check from the saved Instance
    flightUri = (bundle == null) ? null : (Uri) bundle.getParcelable(FlightsContentProvider.CONTENT_ITEM_TYPE);
    // Or passed from the other activity
    if (extras != null) {
        flightUri = extras.getParcelable(FlightsContentProvider.CONTENT_ITEM_TYPE);
        fillData(flightUri);
    }
    // bewaar ingevoerde informatie
    confirmButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mPilotSpin.getSelectedItem().equals(mCoPilotSpin.getSelectedItem())) {
                makeToast("'Gezagvoerder' en 'Co-Piloot' kunnen niet het zelfde zijn !!");
            } else {
                if (TextUtils.isEmpty((String) mRegiSpin.getSelectedItem())) {
                    makeToast("Verplichte velden invullen aub");
                } else {
                    setResult(RESULT_OK);
                    finish();
                }
            }
        }
    });
    // dupliceer de geselecteerde vlucht
    againButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            new AlertDialog.Builder(FlightDetailActivity.this).setTitle("Bevestig deze opdracht")
                    .setMessage("Wilt u deze vlucht dupliceren ? ")
                    .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int whichButton) {
                            // put some caheck in place as t avoid bogus record to be created
                            if ((!mDateText.getText().toString().equals(""))
                                    && (!mStartText.getText().toString().equals(""))
                                    && (!mLandText.getText().toString().equals(""))
                                    && (!mRegiSpin.getSelectedItem().equals(""))
                                    && (!mPilotSpin.getSelectedItem().equals(""))) {
                                ContentValues values = new ContentValues();
                                values.put(GliderLogTables.F_DATE, mDateText.getText().toString());
                                values.put(GliderLogTables.F_REGISTRATION,
                                        (String) mRegiSpin.getSelectedItem());
                                String ftype = "";
                                if (mTypeNorm.isChecked()) {
                                    ftype = "";
                                }
                                if (mTypePass.isChecked()) {
                                    ftype = "PASS";
                                }
                                if (mTypeDona.isChecked()) {
                                    ftype = "DONA";
                                }
                                if (mTypeClub.isChecked()) {
                                    ftype = "CLUB";
                                }
                                values.put(GliderLogTables.F_TYPE, ftype);
                                values.put(GliderLogTables.F_INSTRUCTION, (mInstChck.isChecked()) ? "J" : "N");
                                String fPilo = (String) mPilotSpin.getSelectedItem();
                                values.put(GliderLogTables.F_PILOT, fPilo);
                                String fPilo_id = "";
                                for (int i = 0; i < mPilotSpin.getCount(); i++) {
                                    String s = (String) mPilotSpin.getItemAtPosition(i);
                                    if (s.equalsIgnoreCase(fPilo)) {
                                        fPilo_id = MemberIndexList.get(i);
                                    }
                                }
                                values.put(GliderLogTables.F_PILOT_ID, fPilo_id);
                                String fCoPi = (String) mCoPilotSpin.getSelectedItem();
                                values.put(GliderLogTables.F_COPILOT, fCoPi);
                                String fCoPi_id = "";
                                for (int i = 0; i < mCoPilotSpin.getCount(); i++) {
                                    String s = (String) mCoPilotSpin.getItemAtPosition(i);
                                    if (s.equalsIgnoreCase(fCoPi)) {
                                        fCoPi_id = MemberIndexList.get(i);
                                    }
                                }
                                values.put(GliderLogTables.F_COPILOT_ID, fCoPi_id);
                                values.put(GliderLogTables.F_STARTED, "");
                                values.put(GliderLogTables.F_LANDED, "");
                                values.put(GliderLogTables.F_DURATION, "");
                                String fLaun = "";
                                if (mLaunchWinch.isChecked()) {
                                    fLaun = "L";
                                }
                                if (mLaunchTow.isChecked()) {
                                    fLaun = "S";
                                }
                                if (mLaunchMotor.isChecked()) {
                                    fLaun = "M";
                                }
                                values.put(GliderLogTables.F_LAUNCH, fLaun);
                                values.put(GliderLogTables.F_SENT, "0");
                                values.put(GliderLogTables.F_ACK, "0");
                                values.put(GliderLogTables.F_NOTES, "");
                                // New flight
                                flightUri = getContentResolver()
                                        .insert(FlightsContentProvider.CONTENT_URI_FLIGHT, values);
                            }
                        }
                    }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int whichButton) {
                            // Do nothing.
                        }
                    }).show();
        }
    });

    exitButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            flg_save = true;
            setResult(RESULT_CANCELED);
            finish();
        }
    });

    timeSButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            time_mde = 10;
            // Creating a bundle object to pass currently set time to the fragment
            Bundle b = new Bundle();
            if (!mStartText.getText().toString().isEmpty()) {
                String[] split = mStartText.getText().toString().split(":");
                hour = Integer.parseInt(split[0]);
                minute = Integer.parseInt(split[1]);
            } else {
                final Calendar c = Calendar.getInstance();
                hour = c.get(Calendar.HOUR_OF_DAY);
                minute = c.get(Calendar.MINUTE);
            }
            b.putInt("set_hour", hour);
            b.putInt("set_minute", minute);
            // Instantiating TimePickerDialogFragment & pass it' arguments
            TimePickerDialogFragment timePicker = new TimePickerDialogFragment(mHandler);
            timePicker.setArguments(b);
            // Getting fragment manger for this activity & start transaction
            FragmentManager fm = getSupportFragmentManager();
            FragmentTransaction ft = fm.beginTransaction();
            ft.add(timePicker, "time_picker");
            /** Opening the TimePicker fragment */
            ft.commit();
        }
    });

    timeLButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            time_mde = 20;
            // Creating a bundle object to pass currently set time to the fragment
            Bundle b = new Bundle();
            if (!mLandText.getText().toString().isEmpty()) {
                String[] split = mLandText.getText().toString().split(":");
                hour = Integer.parseInt(split[0]);
                minute = Integer.parseInt(split[1]);
            } else {
                final Calendar c = Calendar.getInstance();
                hour = c.get(Calendar.HOUR_OF_DAY);
                minute = c.get(Calendar.MINUTE);
            }
            b.putInt("set_hour", hour);
            b.putInt("set_minute", minute);
            // Instantiating TimePickerDialogFragment & pass it' arguments
            TimePickerDialogFragment timePicker = new TimePickerDialogFragment(mHandler);
            timePicker.setArguments(b);
            // Getting fragment manger for this activity & start transaction
            FragmentManager fm = getSupportFragmentManager();
            FragmentTransaction ft = fm.beginTransaction();
            ft.add(timePicker, "time_picker");
            /** Opening the TimePicker fragment */
            ft.commit();
        }
    });

    clearSButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            String S_T = mStartText.getText().toString();
            if (S_T.isEmpty()) {
                final Calendar c = Calendar.getInstance();
                //second = c.get(Calendar.SECOND);
                //mStartText.setText(Common.TwoDigits(c.get(Calendar.HOUR_OF_DAY)) + ":" + Common.TwoDigits(c.get(Calendar.MINUTE)));
                mStartText.setText(new StringBuilder().append(Common.TwoDigits(c.get(Calendar.HOUR_OF_DAY)))
                        .append(":").append(Common.TwoDigits(c.get(Calendar.MINUTE))));
            } else {
                mStartText.setText("");
            }
        }
    });

    clearLButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            String L_T = mLandText.getText().toString();
            if (L_T.isEmpty()) {
                final Calendar c = Calendar.getInstance();
                //second = c.get(Calendar.SECOND);
                //mLandText.setText(Common.TwoDigits(c.get(Calendar.HOUR_OF_DAY)) + ":" + Common.TwoDigits(c.get(Calendar.MINUTE)));
                mLandText.setText(new StringBuilder().append(Common.TwoDigits(c.get(Calendar.HOUR_OF_DAY)))
                        .append(":").append(Common.TwoDigits(c.get(Calendar.MINUTE))));
            } else {
                mLandText.setText("");
            }
        }
    });

    mRegiSpin.setOnItemSelectedListener(new Custom0_OnItemSelectedListener());
    mPilotSpin.setOnItemSelectedListener(new Custom1_OnItemSelectedListener());

    gliderButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            // get add_glider.xml view
            LayoutInflater li = LayoutInflater.from(edi_con);
            View promptsView = li.inflate(R.layout.add_glider, null);
            AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(edi_con);
            // set add_glider.xml to alertdialog builder
            alertDialogBuilder.setView(promptsView);
            final EditText userInput1 = (EditText) promptsView.findViewById(R.id.editTextInput1);
            final EditText userInput2 = (EditText) promptsView.findViewById(R.id.editTextInput2);
            final CheckBox userInput3 = (CheckBox) promptsView.findViewById(R.id.editCheckInput3);
            final CheckBox userInput4 = (CheckBox) promptsView.findViewById(R.id.editCheckInput4);
            // set dialog message
            alertDialogBuilder.setCancelable(false)
                    .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                        @Override
                        @SuppressLint("DefaultLocale")
                        public void onClick(DialogInterface dialog, int id) {
                            // user input, convert to UC, add to glider list & spinner
                            result = userInput1.getText().toString().toUpperCase();
                            if (GliderList.contains(result)) {
                                makeToast("Invoer extra, deze kist bestaat reeds !");
                                result = null;
                                dialog.cancel();
                            } else {
                                GliderList.add(result);
                                GliderCall.add(userInput2.getText().toString().toUpperCase());
                                GliderSeatsList.add(userInput3.isChecked() ? "2" : "1");
                                GliderPrivateList.add(userInput4.isChecked() ? "1" : "0");
                                ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(
                                        FlightDetailActivity.this, android.R.layout.simple_spinner_item,
                                        GliderList);
                                dataAdapter
                                        .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                                mRegiSpin.setAdapter(dataAdapter);
                                // add to DB table
                                try {
                                    ContentValues values = new ContentValues();
                                    values.put(GliderLogTables.G_REGISTRATION, result);
                                    getContentResolver().insert(FlightsContentProvider.CONTENT_URI_GLIDER,
                                            values);
                                    values = null;
                                } catch (Exception e) {
                                    Log.e("Exception", "Error: " + e.toString());
                                }
                            }
                        }
                    }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int id) {
                            result = null;
                            dialog.cancel();
                        }
                    });
            // create alert dialog & show it
            AlertDialog alertDialog = alertDialogBuilder.create();
            alertDialog.show();
        }
    });

    pilotButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            // get prompts.xml view
            LayoutInflater li = LayoutInflater.from(edi_con);
            View promptsView = li.inflate(R.layout.add_member, null);
            AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(edi_con);
            // set prompts.xml to alertdialog builder
            alertDialogBuilder.setView(promptsView);
            final EditText userInput = (EditText) promptsView.findViewById(R.id.editTextDialogUserInput);
            // set dialog message
            alertDialogBuilder.setCancelable(false)
                    .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                        @Override
                        @SuppressLint("DefaultLocale")
                        public void onClick(DialogInterface dialog, int id) {
                            // get user input check for at least 2
                            // parts
                            result = userInput.getText().toString();
                            if (MemberList.contains(result)) {
                                makeToast("Invoer extra, deze naam bestaat reeds !");
                                result = null;
                                dialog.cancel();
                            } else {
                                String[] name = result.split(" ");
                                if (name.length < 2) {
                                    makeToast(
                                            "Invoer extra, formaat => Voornaam (tussenvoegsel(s)) Achternaam is vereist !");
                                    result = null;
                                    dialog.cancel();
                                }
                                // add to member list & spinners
                                MemberList.add(result);
                                MemberIndexList.add("" + ini_id);
                                MemberInstrList.add("0");
                                ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(
                                        FlightDetailActivity.this, android.R.layout.simple_spinner_item,
                                        MemberList);
                                dataAdapter
                                        .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                                mPilotSpin.setAdapter(dataAdapter);
                                mCoPilotSpin.setAdapter(dataAdapter);
                                // add parts to DB table fields
                                AddNewMember(name);
                            }
                        }
                    }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int id) {
                            result = null;
                            dialog.cancel();
                        }
                    });
            // create alert dialog & show it
            AlertDialog alertDialog = alertDialogBuilder.create();
            alertDialog.show();
        }
    });

    setMode();
}