Example usage for android.app AlertDialog show

List of usage examples for android.app AlertDialog show

Introduction

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

Prototype

public void show() 

Source Link

Document

Start the dialog and display it on screen.

Usage

From source file:com.max2idea.android.limbo.main.LimboActivity.java

public void promptMachineName(final Activity activity) {
    final AlertDialog alertDialog;
    alertDialog = new AlertDialog.Builder(activity).create();
    alertDialog.setTitle("Machine Name");
    EditText searchView = new EditText(activity);
    searchView.setEnabled(true);/* w w w .j  a v a 2  s .  co m*/
    searchView.setVisibility(View.VISIBLE);
    searchView.setId(201012010);
    searchView.setSingleLine();
    alertDialog.setView(searchView);
    final Handler handler = this.handler;

    // alertDialog.setMessage(body);
    alertDialog.setButton("Create", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {

            // UIUtils.log("Searching...");
            EditText a = (EditText) alertDialog.findViewById(201012010);
            sendHandlerMessage(handler, Const.VM_CREATED, "machine_name", a.getText().toString());
            return;
        }
    });
    alertDialog.show();

}

From source file:fr.cobaltians.cobalt.fragments.CobaltFragment.java

/******************************************************************************************************************
 * ALERT DIALOG//from w w w  .j  a v  a 2s.c  o m
 *****************************************************************************************************************/

private void showAlertDialog(JSONObject data, final String callback) {
    try {
        String title = data.optString(Cobalt.kJSAlertTitle);
        String message = data.optString(Cobalt.kJSMessage);
        boolean cancelable = data.optBoolean(Cobalt.kJSAlertCancelable, false);
        JSONArray buttons = data.has(Cobalt.kJSAlertButtons) ? data.getJSONArray(Cobalt.kJSAlertButtons)
                : new JSONArray();

        AlertDialog alertDialog = new AlertDialog.Builder(mContext).setTitle(title).setMessage(message)
                .create();
        alertDialog.setCancelable(cancelable);

        if (buttons.length() == 0) {
            alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, "OK", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (callback != null) {
                        try {
                            JSONObject data = new JSONObject();
                            data.put(Cobalt.kJSAlertButtonIndex, 0);
                            sendCallback(callback, data);
                        } catch (JSONException exception) {
                            if (Cobalt.DEBUG)
                                Log.e(Cobalt.TAG, TAG + ".AlertDialog - onClick: JSONException");
                            exception.printStackTrace();
                        }
                    }
                }
            });
        } else {
            int buttonsLength = Math.min(buttons.length(), 3);
            for (int i = 0; i < buttonsLength; i++) {
                int buttonId;

                switch (i) {
                case 0:
                default:
                    buttonId = DialogInterface.BUTTON_NEGATIVE;
                    break;
                case 1:
                    buttonId = DialogInterface.BUTTON_NEUTRAL;
                    break;
                case 2:
                    buttonId = DialogInterface.BUTTON_POSITIVE;
                    break;
                }

                alertDialog.setButton(buttonId, buttons.getString(i), new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        if (callback != null) {
                            int buttonIndex;
                            switch (which) {
                            case DialogInterface.BUTTON_NEGATIVE:
                            default:
                                buttonIndex = 0;
                                break;
                            case DialogInterface.BUTTON_NEUTRAL:
                                buttonIndex = 1;
                                break;
                            case DialogInterface.BUTTON_POSITIVE:
                                buttonIndex = 2;
                                break;
                            }

                            try {
                                JSONObject data = new JSONObject();
                                data.put(Cobalt.kJSAlertButtonIndex, buttonIndex);
                                sendCallback(callback, data);
                            } catch (JSONException exception) {
                                if (Cobalt.DEBUG)
                                    Log.e(Cobalt.TAG, TAG + ".AlertDialog - onClick: JSONException");
                                exception.printStackTrace();
                            }
                        }
                    }
                });
            }
        }

        alertDialog.show();
    } catch (JSONException exception) {
        if (Cobalt.DEBUG)
            Log.e(Cobalt.TAG, TAG + " - showAlertDialog: JSONException");
        exception.printStackTrace();
    }
}

From source file:com.max2idea.android.limbo.main.LimboActivity.java

public void promptStateName(final Activity activity) {
    final AlertDialog alertDialog;
    alertDialog = new AlertDialog.Builder(activity).create();
    alertDialog.setTitle("Snapshot/State Name");
    EditText searchView = new EditText(activity);
    searchView.setEnabled(true);//from   www.  ja v a  2s .  c  o m
    searchView.setVisibility(View.VISIBLE);
    searchView.setId(201012010);
    searchView.setSingleLine();
    alertDialog.setView(searchView);
    final Handler handler = this.handler;

    // alertDialog.setMessage(body);
    alertDialog.setButton("Create", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {

            // UIUtils.log("Searching...");
            EditText a = (EditText) alertDialog.findViewById(201012010);
            sendHandlerMessage(handler, Const.SNAPSHOT_CREATED, new String[] { "snapshot_name" },
                    new String[] { a.getText().toString() });
            return;
        }
    });
    alertDialog.show();

}

From source file:cm.aptoide.pt.MainActivity.java

public void showFollow() {
    View socialNetworksView = LayoutInflater.from(this).inflate(R.layout.dialog_social_networks, null);
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this).setView(socialNetworksView);
    final AlertDialog socialDialog = dialogBuilder.create();
    socialDialog.setIcon(android.R.drawable.ic_menu_share);
    socialDialog.setTitle(getString(R.string.social_networks));
    socialDialog.setCancelable(true);/* w ww .j  a v  a2 s.  c  o m*/

    Button facebookButton = (Button) socialNetworksView.findViewById(R.id.find_facebook);
    facebookButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (isAppInstalled("com.facebook.katana")) {
                Intent sharingIntent;
                try {
                    getPackageManager().getPackageInfo("com.facebook.katana", 0);
                    sharingIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/225295240870860"));
                    startActivity(sharingIntent);
                } catch (NameNotFoundException e) {
                    e.printStackTrace();
                }
            } else {
                Intent intent = new Intent(mContext, WebViewFacebook.class);
                startActivity(intent);
            }

        }
    });

    Button twitterButton = (Button) socialNetworksView.findViewById(R.id.follow_twitter);
    twitterButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (isAppInstalled("com.twitter.android")) {
                String url = "http://www.twitter.com/aptoide";
                Intent twitterIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                startActivity(twitterIntent);
            } else {
                Intent intent = new Intent(mContext, WebViewTwitter.class);
                startActivity(intent);
            }
        }
    });
    socialDialog.show();
}

From source file:com.max2idea.android.limbo.main.LimboActivity.java

private void promptPrio(final Activity activity) {
    // TODO Auto-generated method stub

    final AlertDialog alertDialog;
    alertDialog = new AlertDialog.Builder(activity).create();
    alertDialog.setTitle("Enable High Priority!");

    TextView textView = new TextView(activity);
    textView.setVisibility(View.VISIBLE);
    textView.setId(201012010);//from ww w . j  av a2 s .  c om
    textView.setText(
            "Warning! High Priority might increase emulation speed but " + "will slow your phone down!");

    alertDialog.setView(textView);
    final Handler handler = this.handler;

    // alertDialog.setMessage(body);
    alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            LimboSettingsManager.setPrio(activity, true);
        }
    });
    alertDialog.setButton2("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            mPrio.setChecked(false);
            return;
        }
    });
    alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            mPrio.setChecked(false);
        }
    });
    alertDialog.show();
}

From source file:com.guardtrax.ui.screens.HomeScreen.java

private void displaytourInfo() {
    String message = "";
    int i = 0;/*from   ww  w  .  ja  v a 2  s  .  co m*/
    int tagCount = 0;
    boolean singleDisplay = false; //indicates that only 1 item is to be displayed in the tour list
    List<Boolean> tourtagsIncluded = new ArrayList<Boolean>();
    List<Boolean> tourtagsScanned = new ArrayList<Boolean>();
    List<Integer> tourOrder = new ArrayList<Integer>();
    List<String> messageList = new ArrayList<String>();

    //check if this is a single display (second last character of tour name is a space)
    singleDisplay = isSingleRandomTour();
    tourDB.open();

    Cursor c = tourDB.getRecordByTour(GTConstants.tourName);

    if (c != null && c.moveToFirst()) {
        tourtagsScanned = refreshtourtagList(c.getCount(), false, true, false, false);
        tourtagsIncluded = refreshtourtagList(c.getCount(), false, false, true, false);
        tourOrder = gettourOrder(c.getCount());

        //initialize the message array which wil be used to display the messages in the random order
        while (messageList.size() < c.getCount())
            messageList.add("");

        for (i = 0; i < c.getCount(); i++) {
            if (tourtagsScanned.get(i) && tourtagsIncluded.get(i) && !singleDisplay)
                messageList.add(tourOrder.get(i),
                        "<br><font color='#00FF00'>" + c.getString(2) + "</font><br/>");
            else if (!tourtagsScanned.get(i) && !Utility.istourOntime(tourEnd)
                    && Utility.getcurrentState().equals(GTConstants.onShift) && tourtagsIncluded.get(i)
                    && !singleDisplay)
                messageList.add(tourOrder.get(i),
                        "<br><font color='#FF0000'>" + c.getString(2) + "</font><br/>");
            else if (!tourtagsScanned.get(i) && tourtagsIncluded.get(i) && !singleDisplay)
                messageList.add(tourOrder.get(i),
                        "<br><font color='#FFFFFF'>" + c.getString(2) + "</font><br/>");
            else if (singleDisplay && i == touritemNumber)
                messageList.add(tourOrder.get(i),
                        "<br><font color='#FFFFFF'>" + c.getString(2) + "</font><br/>");

            //get the number of tags included
            if (tourtagsIncluded.get(i))
                tagCount++;
            c.moveToNext();
        }
    }

    tourDB.close();

    //create the message string
    for (i = 0; i < messageList.size(); i++)
        if (messageList.get(i).length() > 1)
            message = message + messageList.get(i);

    LayoutInflater inflater = LayoutInflater.from(HomeScreen.this);
    View view = inflater.inflate(R.layout.scroll_dialog, null);

    TextView textview = (TextView) view.findViewById(R.id.dialogtext);
    textview.setText(Html.fromHtml(message));
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(HomeScreen.this);

    //create custom title
    TextView title = new TextView(HomeScreen.this);

    //if this is a single display tour then do not indicate how many tags are in the tour
    if (isSingleRandomTour()) //this is a single display tour
        title.setText(GTConstants.tourName + CRLF + tourTime + CRLF);
    else
        title.setText(GTConstants.tourName + CRLF + tourTime + CRLF + String.valueOf(tagCount) + " Tags");
    title.setPadding(10, 10, 10, 10);
    title.setGravity(Gravity.CENTER);
    title.setTextColor(Color.parseColor("#79ABFF"));
    title.setTextSize(20);
    alertDialog.setCustomTitle(title);

    //alertDialog.setTitle(tourName + CRLF + String.valueOf(i-1) + " Tags"); 
    alertDialog.setView(view);
    alertDialog.setPositiveButton("OK", null);
    AlertDialog alert = alertDialog.create();
    alert.show();
}

From source file:cm.aptoide.pt.RemoteInSearch.java

@Override
protected void onListItemClick(ListView l, View v, final int position, long id) {

    super.onListItemClick(l, v, position, id);

    Vector<String> tmp_get = db.getApk(apk_lst.get(position).apkid);

    String tmp_path = this.getString(R.string.icons_path) + apk_lst.get(position).apkid;
    File test_icon = new File(tmp_path);

    LayoutInflater li = LayoutInflater.from(this);
    View view = li.inflate(R.layout.alertscroll, null);
    Builder alrt = new AlertDialog.Builder(this).setView(view);
    final AlertDialog p = alrt.create();
    if (test_icon.exists() && test_icon.length() > 0) {
        p.setIcon(new BitmapDrawable(tmp_path));
    } else {/*from  w ww . jav a  2  s  .  c o  m*/
        p.setIcon(android.R.drawable.sym_def_app_icon);
    }
    p.setTitle(apk_lst.get(position).name);
    TextView t1 = (TextView) view.findViewById(R.id.n11);
    t1.setText(tmp_get.firstElement());
    TextView t2 = (TextView) view.findViewById(R.id.n22);
    t2.setText(tmp_get.get(1));
    TextView t3 = (TextView) view.findViewById(R.id.n33);
    t3.setText(tmp_get.get(2));
    TextView t4 = (TextView) view.findViewById(R.id.n44);
    t4.setText(tmp_get.get(3));
    TextView t5 = (TextView) view.findViewById(R.id.n55);
    String tmpi = db.getDescript(apk_lst.get(position).apkid);
    if (!(tmpi == null)) {
        t5.setText(tmpi);
    } else {
        t5.setText("No info availale on server. Search market by pressing the button below for more info.");
    }

    p.setButton2("Ok", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            return;
        }
    });
    if (tmp_get.get(2).equalsIgnoreCase("\tno\n")) {
        p.setButton(getString(R.string.install), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                p.dismiss();
                new Thread() {
                    public void run() {
                        String apk_pkg = downloadFile(position);
                        if (apk_pkg == null) {
                            Message msg = new Message();
                            msg.arg1 = 1;
                            download_handler.sendMessage(msg);
                            download_error_handler.sendEmptyMessage(0);
                        } else {
                            installApk(apk_pkg, position);
                        }
                    }
                }.start();
            }
        });
        p.setButton3("Search Market", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                p.dismiss();
                Intent intent = new Intent();
                intent.setAction(android.content.Intent.ACTION_VIEW);
                intent.setData(Uri.parse("market://details?id=" + apk_lst.get(position).apkid));
                startActivity(intent);
            }
        });
    } else {
        p.setButton(getString(R.string.rem), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                String apk_pkg = apk_lst.get(position).apkid;
                removeApk(apk_pkg, position);
            }
        });
        if (apk_lst.get(position).status == 2) {
            p.setButton3(getString(R.string.update), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    p.dismiss();
                    new Thread() {
                        public void run() {
                            String apk_pkg = downloadFile(position);
                            if (apk_pkg == null) {
                                //Toast.makeText(RemoteInSearch.this, "Could not connect to server!", Toast.LENGTH_LONG).show();
                                Message msg = new Message();
                                msg.arg1 = 1;
                                download_handler.sendMessage(msg);
                                download_error_handler.sendEmptyMessage(0);
                            } else {
                                installApk(apk_pkg, position);
                            }
                        }
                    }.start();
                }
            });
        } else {
            p.setButton3("Search Market", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    p.dismiss();
                    Intent intent = new Intent();
                    intent.setAction(android.content.Intent.ACTION_VIEW);
                    intent.setData(Uri.parse("market://details?id=" + apk_lst.get(position).apkid));
                    startActivity(intent);
                }
            });
        }
    }
    p.show();
}

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

public void DoSettings() {
    // get settings.xml view
    LayoutInflater li = LayoutInflater.from(context);
    settingsView = li.inflate(R.layout.settings, null);
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
    // set settings.xml to alertdialog builder
    alertDialogBuilder.setView(settingsView);
    // get user input for service code
    final EditText userInput = (EditText) settingsView.findViewById(R.id.editTextDialogUserInput);
    // set dialog message
    alertDialogBuilder.setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override//from  ww w  .  j a v  a  2s  .  c  om
        public void onClick(DialogInterface dialog, int id) {
            SharedPreferences prefs = context.getSharedPreferences("Share", Context.MODE_PRIVATE);
            prefs.edit().clear();
            SharedPreferences.Editor es = prefs.edit();
            String[] mTestArray;
            if (userInput.getText().toString().equals("NoAccess")) {
                // prefs URL
                EditText et1 = (EditText) settingsView.findViewById(R.id.setting_url);
                appURL = et1.getText().toString();
                es.putString("com.ezac.gliderlogs.url", appURL).apply();
            }
            // prefs PRE
            EditText et2 = (EditText) settingsView.findViewById(R.id.setting_pre);
            appPRE = et2.getText().toString().replace(" ", "");
            es.putString("com.ezac.gliderlogs.pre", appPRE).apply();
            if (userInput.getText().toString().equals("NoAccess")) {
                // prefs SCN
                EditText et3 = (EditText) settingsView.findViewById(R.id.setting_scn);
                appSCN = et3.getText().toString();
                es.putString("com.ezac.gliderlogs.scn", appSCN).apply();
                // prefs KEY
                EditText et4 = (EditText) settingsView.findViewById(R.id.setting_key);
                appKEY = et4.getText().toString();
                es.putString("com.ezac.gliderlogs.key", appKEY).apply();
                // prefs KEY
                EditText et5 = (EditText) settingsView.findViewById(R.id.setting_secret);
                appSCT = et5.getText().toString();
                es.putString("com.ezac.gliderlogs.sct", appSCT).apply();
                // prefs Meteo

                mTestArray = getResources().getStringArray(R.array.meteo_id_arrays);
                Spinner et6 = (Spinner) settingsView.findViewById(R.id.setting_station);
                String sel6 = (String) et6.getSelectedItem();
                //String sel6_id = "";
                for (int i = 0; i < et6.getCount(); i++) {
                    String s1 = (String) et6.getItemAtPosition(i);
                    if (s1.equalsIgnoreCase(sel6)) {
                        appMST = mTestArray[i];
                    }
                }
                es.putString("com.ezac.gliderlogs.mst", appMST).apply();
                // prefs Metar
                EditText et7 = (EditText) settingsView.findViewById(R.id.setting_metar);
                appMTR = et7.getText().toString();
                es.putString("com.ezac.gliderlogs.mst", appMST).apply();
            }
            // prefs Flags
            CheckBox et9a = (CheckBox) settingsView.findViewById(R.id.setting_menu01);
            CheckBox et9b = (CheckBox) settingsView.findViewById(R.id.setting_menu02);

            CheckBox et9c = (CheckBox) settingsView.findViewById(R.id.setting_menu11);
            CheckBox et9d = (CheckBox) settingsView.findViewById(R.id.setting_menu12);
            CheckBox et9e = (CheckBox) settingsView.findViewById(R.id.setting_menu13);
            CheckBox et9f = (CheckBox) settingsView.findViewById(R.id.setting_menu14);
            CheckBox et9g = (CheckBox) settingsView.findViewById(R.id.setting_menu21);
            CheckBox et9h = (CheckBox) settingsView.findViewById(R.id.setting_menu22);
            String et9aa, et9ab;
            String v[];
            if (userInput.getText().toString().equals("To3Myd4T")) {
                et9aa = et9a.isChecked() ? "true" : "false";
                et9ab = et9b.isChecked() ? "true" : "false";
            } else {
                v = appFLG.split(";");
                et9aa = v[0];
                et9ab = v[1];
            }
            String et9ac = et9c.isChecked() ? "true" : "false";
            String et9ad = et9d.isChecked() ? "true" : "false";
            String et9ae = et9e.isChecked() ? "true" : "false";
            String et9af = et9f.isChecked() ? "true" : "false";
            String et9ag = et9g.isChecked() ? "true" : "false";
            String et9ah = et9h.isChecked() ? "true" : "false";
            appFLG = et9aa + ";" + et9ab + ";" + et9ac + ";" + et9ad + ";" + et9ae + ";" + et9af + ";" + et9ag
                    + ";" + et9ah + ";false;false";
            v = appFLG.split(";");

            menu.findItem(R.id.action_ezac).setVisible(Boolean.parseBoolean(v[2]));
            menu.findItem(R.id.action_meteo_group).setVisible(Boolean.parseBoolean(v[3]));
            menu.findItem(R.id.action_ntm_nld).setVisible(Boolean.parseBoolean(v[4]));
            menu.findItem(R.id.action_ntm_blx).setVisible(Boolean.parseBoolean(v[4]));
            menu.findItem(R.id.action_ogn_flarm).setVisible(Boolean.parseBoolean(v[5]));
            menu.findItem(R.id.action_adsb).setVisible(Boolean.parseBoolean(v[6]));
            menu.findItem(R.id.action_adsb_lcl).setVisible(Boolean.parseBoolean(v[7]));
            es.putString("com.ezac.gliderlogs.flg", appFLG).apply();
            // adjust value in menu button to value in use
            MenuItem MenuItem_dur = menu.findItem(R.id.action_45min);
            MenuItem_dur.setTitle(" " + appPRE + " Min ");
            if (userInput.getText().toString().equals("To3Myd4T")) {
                // prefs airfield heading
                mTestArray = getResources().getStringArray(R.array.heading_arrays);
                Spinner et10 = (Spinner) settingsView.findViewById(R.id.setting_heading);
                String sel10 = (String) et10.getSelectedItem();
                //String sel10_id = "";
                for (int i = 0; i < et10.getCount(); i++) {
                    String s2 = (String) et10.getItemAtPosition(i);
                    if (s2.equalsIgnoreCase(sel10)) {
                        appLND = mTestArray[i];
                        es.putString("com.ezac.gliderlogs.lnd", appLND).apply();
                    }
                }
            }
        }
    }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });
    // create alert dialog & and load it's data
    AlertDialog alertDialog = alertDialogBuilder.create();
    EditText et1 = (EditText) settingsView.findViewById(R.id.setting_url);
    EditText et2 = (EditText) settingsView.findViewById(R.id.setting_pre);
    EditText et3 = (EditText) settingsView.findViewById(R.id.setting_scn);
    EditText et4 = (EditText) settingsView.findViewById(R.id.setting_key);
    EditText et5 = (EditText) settingsView.findViewById(R.id.setting_secret);
    Spinner et6 = (Spinner) settingsView.findViewById(R.id.setting_station);
    EditText et7 = (EditText) settingsView.findViewById(R.id.setting_metar);
    //EditText et8 = (EditText) settingsView.findViewById(R.id.setting_ntp);
    CheckBox et9a = (CheckBox) settingsView.findViewById(R.id.setting_menu01);
    CheckBox et9b = (CheckBox) settingsView.findViewById(R.id.setting_menu02);
    CheckBox et9c = (CheckBox) settingsView.findViewById(R.id.setting_menu11);
    CheckBox et9d = (CheckBox) settingsView.findViewById(R.id.setting_menu12);
    CheckBox et9e = (CheckBox) settingsView.findViewById(R.id.setting_menu13);
    CheckBox et9f = (CheckBox) settingsView.findViewById(R.id.setting_menu14);
    CheckBox et9g = (CheckBox) settingsView.findViewById(R.id.setting_menu21);
    CheckBox et9h = (CheckBox) settingsView.findViewById(R.id.setting_menu22);
    Spinner et10 = (Spinner) settingsView.findViewById(R.id.setting_heading);
    et1.setText(appURL);
    et2.setText(appPRE);
    et3.setText(appSCN);
    et4.setText(appKEY);
    et5.setText(appSCT);
    // get settings value for meteo station and set spinner
    String[] mTestArray;
    mTestArray = getResources().getStringArray(R.array.meteo_id_arrays);
    for (int i = 0; i < mTestArray.length; i++) {
        String s = mTestArray[i];
        if (s.equals(appMST)) {
            et6.setSelection(i);
        }
    }
    et7.setText(appMTR);
    // get settings value for menu tabs and set checkboxes
    String v[] = appFLG.split(";");
    et9a.setChecked(Boolean.parseBoolean(v[0]));
    et9b.setChecked(Boolean.parseBoolean(v[1]));
    et9c.setChecked(Boolean.parseBoolean(v[2]));
    et9d.setChecked(Boolean.parseBoolean(v[3]));
    et9e.setChecked(Boolean.parseBoolean(v[4]));
    et9f.setChecked(Boolean.parseBoolean(v[5]));
    et9g.setChecked(Boolean.parseBoolean(v[6]));
    et9h.setChecked(Boolean.parseBoolean(v[7]));
    // re-use mTestArray
    mTestArray = getResources().getStringArray(R.array.heading_arrays);
    for (int i = 0; i < mTestArray.length; i++) {
        String s = mTestArray[i];
        if (s.equals(appLND)) {
            et10.setSelection(i);
        }
    }
    // show it
    alertDialog.show();
}

From source file:com.max2idea.android.limbo.main.LimboActivity.java

public void promptMultiAIO(final Activity activity) {
    // if (!ICS) {
    // Toast.makeText(getApplicationContext(),
    // "Multithread AIO supported only for ICS and above!",
    // Toast.LENGTH_SHORT).show();
    // this.mMultiAIO.setChecked(false);
    // return;/*from   w  w  w. j  a v  a2  s.co m*/
    // }
    final AlertDialog alertDialog;
    alertDialog = new AlertDialog.Builder(activity).create();
    alertDialog.setTitle("Warning!");
    TextView info = new TextView(activity);
    info.setText("Enabling Multithreaded AIO might speed up I/O in the VM "
            + "but it might not work for all devices. "
            + "Multithreaded AIO is experimental and might damage any disk image you open with Limbo so keep a "
            + "backup of your images if you're not certain. "
            + "If you see errors uncheck this option and try again.");
    alertDialog.setView(info);
    final Handler handler = this.handler;
    alertDialog.setButton("Set", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {

            LimboSettingsManager.setMultiAIO(activity, true);

        }
    });
    alertDialog.setButton2("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            mMultiAIO.setChecked(false);
            LimboSettingsManager.setMultiAIO(activity, false);
            return;
        }
    });
    alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            mMultiAIO.setChecked(false);
            LimboSettingsManager.setMultiAIO(activity, false);
        }
    });
    alertDialog.show();

}

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

public void DoFlightMember() {
    // get member_list.xml view
    LayoutInflater li = LayoutInflater.from(context);
    membersView = li.inflate(R.layout.member_list, null);

    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
    // set member_list.xml to alertdialog builder
    alertDialogBuilder.setView(membersView);
    ////from w w  w.  j  a  va  2  s  .  co m
    Button mMember_Btn;
    final EditText mDetailInfo;
    Button mGlider_Btn;
    // set dialog message
    alertDialogBuilder.setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            String fRegi = (String) mGliderSpin.getSelectedItem();
            String fPilo = (String) mMemberSpin.getSelectedItem();
            if (!fPilo.equals("") && !fRegi.equals("")) {
                String fRegiPilo = "";
                for (int i = 0; i < mGliderSpin.getCount(); i++) {
                    String s = (String) mGliderSpin.getItemAtPosition(i);
                    if (s.equalsIgnoreCase(fRegi)) {
                        fRegiPilo = GliderList.get(i);
                    }
                }
                for (int i = 0; i < mMemberSpin.getCount(); i++) {
                    String s = (String) mMemberSpin.getItemAtPosition(i);
                    if (s.equalsIgnoreCase(fPilo)) {
                        fRegiPilo = fRegiPilo + ":" + MemberIndexList.get(i);
                    }
                }
                DoFlightFilter(7, fRegiPilo);
                OptionSelect(R.id.action_my, R.id.action_all, R.id.action_open, R.id.action_ready,
                        R.id.action_45min);
            } else if (!fRegi.equals("")) {
                for (int i = 0; i < mGliderSpin.getCount(); i++) {
                    String s = (String) mGliderSpin.getItemAtPosition(i);
                    if (s.equalsIgnoreCase(fRegi)) {
                        // set filter criteria for selected member
                        DoFlightFilter(6, GliderList.get(i));
                        OptionSelect(R.id.action_my, R.id.action_all, R.id.action_open, R.id.action_ready,
                                R.id.action_45min);
                    }
                }
            } else if (!fPilo.equals("")) {
                for (int i = 0; i < mMemberSpin.getCount(); i++) {
                    String s = (String) mMemberSpin.getItemAtPosition(i);
                    if (s.equalsIgnoreCase(fPilo)) {
                        // set filter criteria for selected member
                        DoFlightFilter(5, MemberIndexList.get(i));
                        OptionSelect(R.id.action_my, R.id.action_all, R.id.action_open, R.id.action_ready,
                                R.id.action_45min);
                    }
                }
            }
        }
    }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            DoFlightFilter(4, "");
            OptionSelect(R.id.action_all, R.id.action_my, R.id.action_open, R.id.action_ready,
                    R.id.action_45min);
            dialog.cancel();
        }
    });
    AlertDialog alertDialog = alertDialogBuilder.create();
    // get reference to and fill spinner with members
    mMemberSpin = (Spinner) membersView.findViewById(R.id.flight_member);
    ArrayAdapter<String> dataAdapter_1 = new ArrayAdapter<String>(FlightOverviewActivity.this,
            android.R.layout.simple_spinner_item, MemberList);
    dataAdapter_1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mMemberSpin.setAdapter(dataAdapter_1);
    // get reference to and fill spinner with gliders
    mGliderSpin = (Spinner) membersView.findViewById(R.id.flight_glider);
    ArrayAdapter<String> dataAdapter_2 = new ArrayAdapter<String>(FlightOverviewActivity.this,
            android.R.layout.simple_spinner_item, GliderList);
    dataAdapter_2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mGliderSpin.setAdapter(dataAdapter_2);
    mDetailInfo = (EditText) membersView.findViewById(R.id.editText1);
    // make field read only
    mDetailInfo.setClickable(false);
    mDetailInfo.setFocusable(false);
    mGlider_Btn = (Button) membersView.findViewById(R.id.flight_glider_detail);
    mGlider_Btn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            String fRegi = (String) mGliderSpin.getSelectedItem();
            if (fRegi.equals(null) || fRegi.equals("")) {
                mDetailInfo.setText("Geen Registratie selectie gevonden,\nmaak een keuze !");
            } else {
                String fRegiPilo = "";
                for (int i = 0; i < mGliderSpin.getCount(); i++) {
                    String s = (String) mGliderSpin.getItemAtPosition(i);
                    if (s.equalsIgnoreCase(fRegi)) {
                        fRegiPilo = GliderList.get(i);
                    }
                }
                mDetailInfo.setText(getDetailInfo(FlightsContentProvider.CONTENT_URI_GLIDER, fRegiPilo, 0));
            }
        }
    });
    mMember_Btn = (Button) membersView.findViewById(R.id.flight_member_detail);
    mMember_Btn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            String fPilo = (String) mMemberSpin.getSelectedItem();
            if (fPilo.equals(null) || fPilo.equals("")) {
                mDetailInfo.setText("Geen Naam selectie gevonden,\nmaak een keuze !");
            } else {
                String fRegiPilo = "";
                for (int i = 0; i < mMemberSpin.getCount(); i++) {
                    String s = (String) mMemberSpin.getItemAtPosition(i);
                    if (s.equalsIgnoreCase(fPilo)) {
                        fRegiPilo = MemberIndexList.get(i);
                    }
                }
                mDetailInfo.setText(getDetailInfo(FlightsContentProvider.CONTENT_URI_MEMBER, fRegiPilo, 1));
            }
        }
    });
    alertDialog.show();
}