Example usage for android.app AlertDialog.Builder setTitle

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

Introduction

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

Prototype

@Override
    public void setTitle(CharSequence title) 

Source Link

Usage

From source file:edu.missouri.bas.activities.AdminManageActivity.java

private Dialog AdminPinDialog(Context context) {
    LayoutInflater inflater = LayoutInflater.from(this);
    final View textEntryView = inflater.inflate(R.layout.pin_login, null);
    alert_text = (TextView) textEntryView.findViewById(R.id.pin_text);
    alert_text.setText("Please input PIN for administrator");
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setCancelable(false);//from   w  w  w  .  java  2  s  . c  om
    builder.setTitle("Verify Admin PIN");
    builder.setView(textEntryView);
    //builder.setMessage("Please input PIN for administrator");
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {

            //check networking

            adminPin = (EditText) textEntryView.findViewById(R.id.pin_edit);
            String AdPin = adminPin.getText().toString();
            Log.d(TAG, "get from edittext is " + AdPin);

            HttpPost request = new HttpPost(
                    "http://dslsrv8.cs.missouri.edu/~rs79c/Server/Crt/validateUser.php");

            List<NameValuePair> params = new ArrayList<NameValuePair>();

            //file_name 
            params.add(new BasicNameValuePair("userID", "0000"));
            //function
            params.add(new BasicNameValuePair("pre", "1"));
            //data                       
            params.add(new BasicNameValuePair("password", AdPin));

            try {
                request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));

                HttpResponse response = new DefaultHttpClient().execute(request);
                if (response.getStatusLine().getStatusCode() == 200) {
                    String result = EntityUtils.toString(response.getEntity());
                    Log.d("~~~~~~~~~~http post result", result);

                    if (result.equals("AdminIsChecked")) {
                        //do nothing

                        //setResult(8);
                    } else if (result.equals("AdminPinIsInvalid")) {

                        imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                        imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                        Toast toast = Toast.makeText(getApplicationContext(),
                                "Admin PIN is wrong, exit! Please try again.", Toast.LENGTH_SHORT);
                        toast.show();
                        //set return code
                        /*                            if(shp.getString(ASID, "").equals("")){
                                                       setResult(9);
                                                    }else{
                                                       setResult(Activity.RESULT_CANCELED);
                                                    }*/
                        //setResult(9);
                        finish();
                    } else {

                        imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                        imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                        Toast toast = Toast.makeText(getApplicationContext(),
                                "Verify failed. Please try again.", Toast.LENGTH_SHORT);
                        toast.show();
                        //set return code
                        /*                            if(shp.getString(ASID, "").equals("")){
                                                       setResult(9);
                                                    }else{
                                                       setResult(Activity.RESULT_CANCELED);
                                                    }*/
                        finish();
                    }

                }
            } catch (Exception e) {
                // TODO Auto-generated catch block

                imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                Toast toast = Toast.makeText(getApplicationContext(),
                        "Failed. Please try again, with network connection.", Toast.LENGTH_SHORT);
                toast.show();
                //set return code
                /*                        if(shp.getString(ASID, "").equals("")){
                   setResult(9);
                }else{
                   setResult(Activity.RESULT_CANCELED);
                }*/

                finish();
                e.printStackTrace();
            }

        }
    });
    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {

            imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
            imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

            //set return code
            /*                    if(shp.getString(ASID, "").equals("")){
               setResult(9);
            }else{
               setResult(Activity.RESULT_CANCELED);
            }*/
            setResult(9);
            finish();
        }
    });
    return builder.create();
}

From source file:git.lawpavilionprime.auth._Login.java

public void connectIfInternetIsAvailable() {
    if (config.isConnectingToInternet()) {
        txtProgressMessage.setText("Please wait...");
        mProgressBar.setVisibility(View.VISIBLE);

        AsyncManager.runBackgroundTask(new _AsyncLogin());

    } else {/*w w  w  . ja v  a  2  s. co m*/
        AlertDialog.Builder builder = new AlertDialog.Builder(_Login.this);
        builder.setTitle("Error");
        builder.setMessage("Oops! Something went wrong!\n\nplease check your internet connection")
                .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                        mProgressBar.setVisibility(View.GONE);
                    }
                }).setPositiveButton("Retry", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        connectIfInternetIsAvailable();
                    }
                });
        AlertDialog dialog = builder.create();
        dialog.show();
    }
}

From source file:fr.pasteque.client.Configure.java

@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
    if (preference.getKey().equals("printer_driver")) {
        // On printer driver update, change models
        if (newValue.equals("EPSON ePOS") && !Compat.isEpsonPrinterCompatible()) {
            Toast t = Toast.makeText(this, R.string.not_compatible, Toast.LENGTH_SHORT);
            t.show();//from  ww  w . j ava  2 s . com
            return false;
        } else if ((newValue.equals("LK-PXX") && !Compat.isLKPXXPrinterCompatible())
                || (newValue.equals("Woosim") && !Compat.isWoosimPrinterCompatible())) {
            Toast t = Toast.makeText(this, R.string.not_compatible, Toast.LENGTH_SHORT);
            t.show();
            return false;
        }
        this.updatePrinterPrefs(newValue);
    } else if ("card_processor".equals(preference.getKey())) {
        if ("payleven".equals(newValue) && !Compat.hasPaylevenApp(this)) {
            // Trying to enable payleven without app: download
            AlertDialog.Builder b = new AlertDialog.Builder(this);
            b.setTitle(R.string.config_payleven_download_title);
            b.setMessage(R.string.config_payleven_download_message);
            b.setIcon(android.R.drawable.ic_dialog_info);
            b.setNegativeButton(android.R.string.cancel, null);
            b.setPositiveButton(R.string.config_payleven_download_ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    Intent i = new Intent(Intent.ACTION_VIEW,
                            Uri.parse("market://details?id=de.payleven.androidphone"));
                    Configure.this.startActivity(i);
                }
            });
            b.show();
            return false;
        }
        this.updateCardProcessorPreferences((String) newValue);
    }
    return true;
}

From source file:git.lawpavilionprime.auth._Login.java

@Override
public void onBackPressed() {

    if (isAsyncTaskRunning) {
        AlertDialog.Builder builder = new AlertDialog.Builder(_Login.this);
        builder.setTitle("Info");
        builder.setMessage(/*from  w w  w .j a  v  a2  s.co m*/
                "You are about to  exit the application\n\nYour Login is almost complete, Do you want to continue?")
                .setNegativeButton("Yes", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Log.d("BACK", "BACK PRESSED");
                        mProgressBar.setVisibility(View.GONE);
                        AsyncManager.cancelAllTasks();
                        _Login.this.finish();
                    }
                }).setPositiveButton("No", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                    }
                });
        backPressedDialog = builder.create();
        backPressedDialog.show();
    } else {
        super.onBackPressed();
    }
}

From source file:com.mercandalli.android.apps.files.user.community.UserFragment.java

public void updateAdapter() {
    if (mRecyclerView != null && isAdded()) {
        mCircularProgressBar.setVisibility(View.GONE);

        if (mUserModels.size() == 0) {
            mMessageTextView.setText(getString(R.string.no_user));
            mMessageTextView.setVisibility(View.VISIBLE);
        } else {//from   w w  w . j  a v a2  s .c om
            mMessageTextView.setVisibility(View.GONE);
        }

        final AdapterModelUser adapterModelUser = new AdapterModelUser(mUserModels, new IModelUserListener() {
            @Override
            public void execute(final UserModel userModel) {
                final AlertDialog.Builder menuAlert = new AlertDialog.Builder(getContext());
                String[] menuList = { getString(R.string.talk) };
                if (Config.isUserAdmin()) {
                    menuList = new String[] { getString(R.string.talk), getString(R.string.delete) };
                }
                menuAlert.setTitle(getString(R.string.action));
                menuAlert.setItems(menuList, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int item) {
                        switch (item) {
                        case 0:
                            DialogUtils.prompt(getContext(), "Send Message", "Write your message", "Send",
                                    new DialogUtils.OnDialogUtilsStringListener() {
                                        @Override
                                        public void onDialogUtilsStringCalledBack(String text) {
                                            String url = Constants.URL_DOMAIN + Config.ROUTE_USER_CONVERSATION
                                                    + "/" + userModel.getId();
                                            List<StringPair> parameters = new ArrayList<>();
                                            parameters.add(new StringPair("message", "" + text));

                                            new TaskPost(getActivity(), url, new IPostExecuteListener() {
                                                @Override
                                                public void onPostExecute(JSONObject json, String body) {

                                                }
                                            }, parameters).execute();
                                        }
                                    }, getString(android.R.string.cancel), null);
                            break;
                        case 1:
                            DialogUtils.alert(getContext(), "Delete " + userModel.username + "?",
                                    "This process cannot be undone.", getString(R.string.delete),
                                    new DialogUtils.OnDialogUtilsListener() {
                                        @Override
                                        public void onDialogUtilsCalledBack() {
                                            if (Config.isUserAdmin()) {
                                                userModel.delete(getActivity(), new IPostExecuteListener() {
                                                    @Override
                                                    public void onPostExecute(JSONObject json, String body) {
                                                        UserFragment.this.refreshList();
                                                    }
                                                });
                                            } else {
                                                Toast.makeText(getActivity(), "Not permitted.",
                                                        Toast.LENGTH_SHORT).show();
                                            }
                                        }
                                    }, getString(android.R.string.cancel), null);
                            break;
                        }
                    }
                });
                AlertDialog menuDrop = menuAlert.create();
                menuDrop.show();
            }
        });
        mRecyclerView.setAdapter(adapterModelUser);

        if ((mRootView.findViewById(R.id.circle)).getVisibility() == View.GONE) {
            (mRootView.findViewById(R.id.circle)).setVisibility(View.VISIBLE);
            Animation animOpen = AnimationUtils.loadAnimation(getContext(), R.anim.circle_button_bottom_open);
            (mRootView.findViewById(R.id.circle)).startAnimation(animOpen);
        }

        (mRootView.findViewById(R.id.circle)).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // TODO Fab UserFragment
                Toast.makeText(getActivity(), getString(R.string.not_implemented), Toast.LENGTH_SHORT).show();
            }
        });

        adapterModelUser.setOnItemClickListener(new AdapterModelUser.OnItemClickListener() {
            @Override
            public void onItemClick(View view, int position) {

            }
        });

        mSwipeRefreshLayout.setRefreshing(false);
    }
}

From source file:com.google.zxing.client.android.result.ResultHandler.java

/**
 * Like {@link #rawLaunchIntent(Intent)} but will show a user dialog if nothing is available to handle.
 *///  w w w  . j  av  a  2s. c o  m
final void launchIntent(Intent intent) {
    try {
        rawLaunchIntent(intent);
    } catch (ActivityNotFoundException ignored) {
        AlertDialog.Builder builder = new AlertDialog.Builder(activity);
        builder.setTitle(R.string.app_name);
        builder.setMessage(R.string.msg_intent_failed);
        builder.setPositiveButton(R.string.button_ok, null);
        builder.show();
    }
}

From source file:com.azure.webapi.LoginManager.java

/**
 * Creates the UI for the interactive authentication process
 * //from  www  .  ja  va  2s  . c  om
 * @param provider
 *            The provider used for the authentication process
 * @param startUrl
 *            The initial URL for the authentication process
 * @param endUrl
 *            The final URL for the authentication process
 * @param context
 *            The context used to create the authentication dialog
 * @param callback
 *            Callback to invoke when the authentication process finishes
 */
protected void showLoginUI(MobileServiceAuthenticationProvider provider, final String startUrl,
        final String endUrl, final Context context, LoginUIOperationCallback callback) {
    if (startUrl == null || startUrl == "") {
        throw new IllegalArgumentException("startUrl can not be null or empty");
    }

    if (endUrl == null || endUrl == "") {
        throw new IllegalArgumentException("endUrl can not be null or empty");
    }

    if (context == null) {
        throw new IllegalArgumentException("context can not be null");
    }

    final LoginUIOperationCallback externalCallback = callback;
    final AlertDialog.Builder builder = new AlertDialog.Builder(context);
    // Create the Web View to show the login page
    final WebView wv = new WebView(context);
    builder.setTitle("Connecting to a service");
    builder.setCancelable(true);
    builder.setOnCancelListener(new DialogInterface.OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            if (externalCallback != null) {
                externalCallback.onCompleted(null, new MobileServiceException("User Canceled"));
            }
        }
    });

    // Set cancel button's action
    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (externalCallback != null) {
                externalCallback.onCompleted(null, new MobileServiceException("User Canceled"));
            }
            wv.destroy();
        }
    });

    wv.getSettings().setJavaScriptEnabled(true);

    wv.requestFocus(View.FOCUS_DOWN);
    wv.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View view, MotionEvent event) {
            int action = event.getAction();
            if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_UP) {
                if (!view.hasFocus()) {
                    view.requestFocus();
                }
            }

            return false;
        }
    });

    // Create a LinearLayout and add the WebView to the Layout
    LinearLayout layout = new LinearLayout(context);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.addView(wv);

    // Add a dummy EditText to the layout as a workaround for a bug
    // that prevents showing the keyboard for the WebView on some devices
    EditText dummyEditText = new EditText(context);
    dummyEditText.setVisibility(View.GONE);
    layout.addView(dummyEditText);

    // Add the layout to the dialog
    builder.setView(layout);

    final AlertDialog dialog = builder.create();

    wv.setWebViewClient(new WebViewClient() {

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            // If the URL of the started page matches with the final URL
            // format, the login process finished
            if (isFinalUrl(url)) {
                if (externalCallback != null) {
                    externalCallback.onCompleted(url, null);
                }

                dialog.dismiss();
            }

            super.onPageStarted(view, url, favicon);
        }

        // Checks if the given URL matches with the final URL's format
        private boolean isFinalUrl(String url) {
            if (url == null) {
                return false;
            }

            return url.startsWith(endUrl);
        }

        // Checks if the given URL matches with the start URL's format
        private boolean isStartUrl(String url) {
            if (url == null) {
                return false;
            }

            return url.startsWith(startUrl);
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            if (isStartUrl(url)) {
                if (externalCallback != null) {
                    externalCallback.onCompleted(null, new MobileServiceException(
                            "Logging in with the selected authentication provider is not enabled"));
                }

                dialog.dismiss();
            }
        }
    });

    wv.loadUrl(startUrl);
    dialog.show();
}

From source file:li.barter.fragments.ChatsFragment.java

@Override
public void onDialogClick(final DialogInterface dialog, final int which) {

    if ((mChatDialogFragment != null) && mChatDialogFragment.getDialog().equals(dialog)) {

        if (which == 0) {

            final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());

            // set title
            alertDialogBuilder.setTitle("Confirm");

            // set dialog message
            alertDialogBuilder.setMessage(getResources().getString(R.string.delete_chat_alert_message))
                    .setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(final DialogInterface dialog, final int id) {

                            deleteChat(mDeleteChatId);
                            dialog.dismiss();
                        }//w w  w.j  a  v a  2s  .  c o m
                    }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(final DialogInterface dialog, final int id) {
                            // if this button is clicked, just close
                            // the dialog box and do nothing
                            dialog.cancel();
                        }
                    });

            // create alert dialog
            final AlertDialog alertDialog = alertDialogBuilder.create();

            // show it
            alertDialog.show();

        } else if (which == 1) {

            final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());

            // set title
            alertDialogBuilder.setTitle("Confirm");

            // set dialog message
            alertDialogBuilder.setMessage(getResources().getString(R.string.block_user_alert_message))
                    .setCancelable(false).setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(final DialogInterface dialog, final int id) {

                            blockUser(mBlockUserId);
                            dialog.dismiss();
                        }
                    }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(final DialogInterface dialog, final int id) {
                            // if this button is clicked, just close
                            // the dialog box and do nothing
                            dialog.cancel();
                        }
                    });

            // create alert dialog
            final AlertDialog alertDialog = alertDialogBuilder.create();

            // show it
            alertDialog.show();

        }
    } else {
        super.onDialogClick(dialog, which);
    }
}

From source file:org.openhab.habdroid.ui.OpenHABRoomSettingActivity.java

private void showSitemapSelectionDialog(final List<OpenHABSitemap> sitemapList) {
    Log.i(TAG, "Opening sitemap selection dialog");
    final List<String> sitemapNameList = new ArrayList<String>();
    ;/*  w  w  w  . j  a  va  2  s .co  m*/
    for (int i = 0; i < sitemapList.size(); i++) {
        sitemapNameList.add(sitemapList.get(i).getName());
    }
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(OpenHABRoomSettingActivity.this);
    dialogBuilder.setTitle("Select sitemap");
    dialogBuilder.setItems(sitemapNameList.toArray(new CharSequence[sitemapNameList.size()]),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int item) {
                    Log.i(TAG, "Selected sitemap " + sitemapNameList.get(item));
                    SharedPreferences settings = PreferenceManager
                            .getDefaultSharedPreferences(OpenHABRoomSettingActivity.this);
                    Editor preferencesEditor = settings.edit();
                    preferencesEditor.putString("default_openhab_sitemap", sitemapList.get(item).getName());
                    preferencesEditor.commit();
                    openSitemap(sitemapList.get(item).getHomepageLink());
                }
            }).show();
}

From source file:com.google.android.apps.paco.ExploreDataActivity.java

private View renderMultiSelectListButton(final Long id, final TextView textview) {

    DialogInterface.OnMultiChoiceClickListener multiselectListDialogListener = new DialogInterface.OnMultiChoiceClickListener() {
        @Override/*from   w w  w.j  a  v  a  2 s .  c  o m*/
        public void onClick(DialogInterface dialog, int which, boolean isChecked) {
            if (isChecked) {
                if (checkedChoices.get(id) != null) {
                    checkedChoices.get(id).add(inputIds.get(which));
                } else {
                    List<Long> tempList = new ArrayList<Long>();
                    tempList.add(inputIds.get(which));
                    checkedChoices.put(id, tempList);
                }
            } else {
                checkedChoices.get(id).remove(inputIds.get(which));
                if (checkedChoices.get(id).isEmpty())
                    checkedChoices.remove(id);
            }
        }
    };

    AlertDialog.Builder builder = new AlertDialog.Builder(mainLayout.getContext());
    builder.setTitle(R.string.make_selections);

    boolean[] checkedChoicesBoolArray = new boolean[inputIds.size()];
    int count = inputIds.size();

    if (checkedChoices.get(id) != null) {
        for (int i = 0; i < count; i++) {
            checkedChoicesBoolArray[i] = checkedChoices.get(id).contains(inputIds.get(i));
        }
    }
    String[] listChoices = new String[inputIds.size()];
    inpNames.toArray(listChoices);
    builder.setMultiChoiceItems(listChoices, checkedChoicesBoolArray, multiselectListDialogListener);
    builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int whichButton) {
            getLabelWithSelectedVariables(id, textview);
        }
    });
    AlertDialog multiSelectListDialog = builder.create();
    multiSelectListDialog.show();
    return multiSelectListDialog.getListView();
}