Example usage for android.app AlertDialog.Builder setView

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

Introduction

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

Prototype

public void setView(View view) 

Source Link

Document

Set the view to display in that dialog.

Usage

From source file:com.agustinprats.myhrv.fragment.MonitorFragment.java

/** Shows the connect dialog displaying a list of available devices to connect */
private void showConnectDialog() {

    LayoutInflater inflater = getMainActivity().getLayoutInflater();

    // Init view/*from  w  w w  .j a v  a  2 s .co m*/
    RelativeLayout devicesDialogView = (RelativeLayout) inflater.inflate(R.layout.devices_dialog, null);

    AlertDialog.Builder devicesDialogBuilder = new AlertDialog.Builder(getMainActivity());
    devicesDialogBuilder.setTitle(R.string.devices_available);
    devicesDialogBuilder.setView(devicesDialogView);
    final AlertDialog devicesDialog = devicesDialogBuilder.create();

    _searchingDevicesText = (TextView) devicesDialogView.findViewById(R.id.searchingText);

    ListView listView = (ListView) devicesDialogView.findViewById(R.id.listView);
    listView.setEmptyView(_searchingDevicesText);
    final HeartRateDeviceListAdapter mHeartRateDeviceListAdapter = new HeartRateDeviceListAdapter(inflater);
    _heartRateDeviceListAdapter = mHeartRateDeviceListAdapter;

    final HeartRateService service = getMainActivity().getHeartRateService();
    service.startScanningDevices();
    listView.setAdapter(mHeartRateDeviceListAdapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            final HeartRateDevice device = mHeartRateDeviceListAdapter.getDevice(position);
            if (device != null) {

                if (service.isScanning())
                    service.stopScanningDevices();

                Log.d(TAG, "connecting from devices dialog");
                service.connect(device.getAddress());
            }
            devicesDialog.dismiss();
        }
    });

    devicesDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {

            service.stopScanningDevices();
            _heartRateDeviceListAdapter = null;
        }
    });

    devicesDialog.show();
}

From source file:com.linkbubble.util.YouTubeEmbedHelper.java

private AlertDialog getMultipleEmbedsDialog() {
    if (embedInfoMatchesIds()) {
        return getEmbedResultsDialog();
    } else {//from   w  w w. ja v a 2  s .  co  m
        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);

        LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.view_loading, null);

        TextView textView = (TextView) view.findViewById(R.id.loading_text);
        textView.setText(R.string.loading_youtube_embed_info);

        builder.setView(view);
        builder.setIcon(0);

        AlertDialog alertDialog = builder.create();
        alertDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);

        if (mCurrentDownloadTask != null) {
            synchronized (mCurrentDownloadTask) {
                if (mCurrentDownloadTask != null) {
                    mCurrentDownloadTask.cancel(true);
                }
                mCurrentDownloadTask = new DownloadYouTubeEmbedInfoTask(true, alertDialog);
                mCurrentDownloadTask.execute(null, null, null);
            }
        } else {
            mCurrentDownloadTask = new DownloadYouTubeEmbedInfoTask(true, alertDialog);
            mCurrentDownloadTask.execute(null, null, null);
        }

        return alertDialog;
    }
}

From source file:com.andrewshu.android.reddit.mail.InboxActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    Dialog dialog;//from   w ww .j a  va 2s  .c  o  m
    ProgressDialog pdialog;
    AlertDialog.Builder builder;
    LayoutInflater inflater;
    View layout; // used for inflated views for AlertDialog.Builder.setView()

    switch (id) {
    case Constants.DIALOG_COMPOSE:
        inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        builder = new AlertDialog.Builder(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        layout = inflater.inflate(R.layout.compose_dialog, null);
        dialog = builder.setView(layout).create();
        final Dialog composeDialog = dialog;

        Common.setTextColorFromTheme(mSettings.getTheme(), getResources(),
                (TextView) layout.findViewById(R.id.compose_destination_textview),
                (TextView) layout.findViewById(R.id.compose_subject_textview),
                (TextView) layout.findViewById(R.id.compose_message_textview),
                (TextView) layout.findViewById(R.id.compose_captcha_textview),
                (TextView) layout.findViewById(R.id.compose_captcha_loading));

        final EditText composeDestination = (EditText) layout.findViewById(R.id.compose_destination_input);
        final EditText composeSubject = (EditText) layout.findViewById(R.id.compose_subject_input);
        final EditText composeText = (EditText) layout.findViewById(R.id.compose_text_input);
        final Button composeSendButton = (Button) layout.findViewById(R.id.compose_send_button);
        final Button composeCancelButton = (Button) layout.findViewById(R.id.compose_cancel_button);
        final EditText composeCaptcha = (EditText) layout.findViewById(R.id.compose_captcha_input);
        composeSendButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                ThingInfo thingInfo = new ThingInfo();

                if (!FormValidation.validateComposeMessageInputFields(InboxActivity.this, composeDestination,
                        composeSubject, composeText, composeCaptcha))
                    return;

                thingInfo.setDest(composeDestination.getText().toString().trim());
                thingInfo.setSubject(composeSubject.getText().toString().trim());
                new MyMessageComposeTask(composeDialog, thingInfo, composeCaptcha.getText().toString().trim(),
                        mCaptchaIden, mSettings, mClient, InboxActivity.this)
                                .execute(composeText.getText().toString().trim());
                removeDialog(Constants.DIALOG_COMPOSE);
            }
        });
        composeCancelButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                removeDialog(Constants.DIALOG_COMPOSE);
            }
        });
        break;

    case Constants.DIALOG_COMPOSING:
        pdialog = new ProgressDialog(new ContextThemeWrapper(this, mSettings.getDialogTheme()));
        pdialog.setMessage("Composing message...");
        pdialog.setIndeterminate(true);
        pdialog.setCancelable(true);
        dialog = pdialog;
        break;
    default:
        throw new IllegalArgumentException("Unexpected dialog id " + id);
    }
    return dialog;
}

From source file:com.example.skode6.scanenvy.MainActivity.java

private AlertDialog enterDialog(final EditText edit) {
    AlertDialog.Builder dialog = new AlertDialog.Builder(this);

    edit.setKeyListener(new DigitsKeyListener());
    final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(edit, InputMethodManager.SHOW_IMPLICIT);
    //edit.setFocusableInTouchMode(true);
    edit.setFocusable(true);//from w w  w .  j ava 2 s .c om
    //edit.setOnClickListener(clickText());
    //edit.requestFocusFromTouch();
    edit.requestFocus();

    dialog.setView(edit);
    dialog.setCancelable(true);
    dialog.setTitle("Enter UPC");
    dialog.setPositiveButton("Submit", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            String upc = edit.getText().toString();
            try {
                Product p = run.lookUp(upc);
                adapter.add(p);
                //run.addProduct(p);
            } catch (IOException e) {
                Toast error = Toast.makeText(getApplicationContext(), "Couldn't find" + upc, Toast.LENGTH_LONG);
                error.show();
            }
        }
    });
    dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });
    return dialog.create();
}

From source file:com.example.sujit.customerapp.Get_Taxi.java

private void insert(String username, String taxi_number, String license_number, String mobile_number,
        String full_name, String address) {
    LayoutInflater li = LayoutInflater.from(this);
    //Creating a view to get the dialog box
    View confirmDialog = li.inflate(R.layout.dialog_drivercall, null);

    buttonCall2 = (AppCompatButton) confirmDialog.findViewById(R.id.buttonCall2);
    textViewName2 = (TextView) confirmDialog.findViewById(R.id.textViewName2);
    textViewLicenseNo2 = (TextView) confirmDialog.findViewById(R.id.textViewLicenseNo2);
    textViewAddress2 = (TextView) confirmDialog.findViewById(R.id.textViewAddress2);
    textViewMobile2 = (TextView) confirmDialog.findViewById(R.id.textViewMobile2);
    textViewTaxiNo2 = (TextView) confirmDialog.findViewById(R.id.textViewTaxiNo2);
    textusername2 = (TextView) confirmDialog.findViewById(R.id.textusername2);

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

    //Adding our dialog box to the view of alert dialog
    alert.setView(confirmDialog);

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

    //Displaying the alert dialog
    alertDialog.show();/*ww  w  . j a  v a 2s.c o m*/

    textusername2.setText(username);
    textViewTaxiNo2.setText(taxi_number);
    textViewLicenseNo2.setText(license_number);
    textViewMobile2.setText(mobile_number);
    textViewName2.setText(full_name);
    textViewAddress2.setText(address);

    buttonCall2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Toast.makeText(Get_Taxi.this, (CharSequence) textViewMobile1, Toast.LENGTH_LONG).show();
        }
    });
}

From source file:ch.jeda.platform.android.InputDialogFragment.java

@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final AlertDialog.Builder builder = new AlertDialog.Builder(this.getActivity());
    builder.setTitle(this.request.getTitle());
    builder.setMessage(this.request.getMessage());
    this.input = new EditText(this.getActivity());
    // This is required in order to show soft keyboard when input is focused.
    this.input.setFocusableInTouchMode(true);
    this.input.setImeOptions(EditorInfo.IME_ACTION_DONE);
    this.input.setInputType(EditorInfo.TYPE_CLASS_TEXT);
    this.input.addTextChangedListener(this);
    final InputMethodManager imm = (InputMethodManager) getActivity()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(this.input, InputMethodManager.SHOW_IMPLICIT);
    builder.setView(this.input);
    builder.setPositiveButton("OK", this);
    builder.setNegativeButton("Abbrechen", this);
    return builder.create();
}

From source file:com.codeskraps.sbrowser.home.SBrowserActivity.java

private void doSearch() {
    final AlertDialog.Builder alertSearch = new AlertDialog.Builder(this);
    alertSearch.setTitle(getResources().getString(R.string.alertSearchTitle));
    alertSearch.setMessage(getResources().getString(R.string.alertSearchSummary));
    final EditText inputSearch = new EditText(this);
    inputSearch.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_VARIATION_URI);
    alertSearch.setView(inputSearch);
    alertSearch.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            String value = inputSearch.getText().toString().trim();
            webView.loadUrl("https://encrypted.google.com/search?q=" + value);
        }/*from w  w  w  .  ja  va2  s.c o m*/
    });

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

From source file:com.example.sujit.customerapp.Get_Taxi.java

private void showDialog(Double distance) {
    String dis = String.valueOf(distance);

    LayoutInflater li = LayoutInflater.from(this);
    //Creating a view to get the dialog box
    View confirmDialog = li.inflate(R.layout.dialog_distance, null);

    //Initizliaing confirm button fo dialog box and edit text of dialog box
    buttonSelect = (AppCompatButton) confirmDialog.findViewById(R.id.buttonSelect);
    buttonAssign = (AppCompatButton) confirmDialog.findViewById(R.id.buttonAssign);

    textView1 = (TextView) confirmDialog.findViewById(R.id.textView1);
    textView2 = (TextView) confirmDialog.findViewById(R.id.textView2);

    textView1.setText(dis);/*from  ww w . ja v a2 s  . c  o m*/
    //textView2.setText(time);

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

    //Adding our dialog box to the view of alert dialog
    alert.setView(confirmDialog);

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

    //Displaying the alert dialog
    alertDialog.show();

    buttonSelect.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            alertDialog.dismiss();
            getDrivers();
        }
    });
    buttonAssign.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            alertDialog.dismiss();
            showProfile();
        }
    });
}

From source file:jp.watnow.plugins.dialog.Notification.java

/**
 * // w  w w  .  ja v a  2s.  co m
 * @param message
 * @param title
 * @param buttonLabels
 * @param defaultTexts
 * @param callbackContext
 */
public synchronized void login(final String title, final String message, final JSONArray buttonLabels,
        final JSONArray defaultTexts, final CallbackContext callbackContext) {

    final CordovaInterface cordova = this.cordova;

    Runnable runnable = new Runnable() {
        public void run() {
            LinearLayout layout = new LinearLayout(cordova.getActivity());
            layout.setOrientation(LinearLayout.VERTICAL);
            layout.setPadding(10, 0, 10, 0);
            final EditText usernameInput = new EditText(cordova.getActivity());
            usernameInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL);
            final EditText passwordInput = new EditText(cordova.getActivity());
            passwordInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
            try {
                usernameInput.setHint("ID");
                usernameInput.setText(defaultTexts.getString(0));
                passwordInput.setHint("PASSWORD");
                passwordInput.setText(defaultTexts.getString(1));
            } catch (JSONException e1) {
            }

            layout.addView(usernameInput, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT));
            layout.addView(passwordInput, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT));

            AlertDialog.Builder dlg = createDialog(cordova); // new AlertDialog.Builder(cordova.getActivity(), AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
            dlg.setMessage(message);
            dlg.setTitle(title);
            dlg.setCancelable(false);

            dlg.setView(layout);

            final JSONObject result = new JSONObject();

            try {
                dlg.setNegativeButton(buttonLabels.getString(0), new AlertDialog.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        try {
                            result.put("buttonIndex", 1);
                            result.put("input1", usernameInput.getText());
                            result.put("input2", passwordInput.getText());
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                        callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
                    }
                });
            } catch (JSONException e) {
            }

            try {
                dlg.setPositiveButton(buttonLabels.getString(1), new AlertDialog.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        try {
                            result.put("buttonIndex", 3);
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                        callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
                    }
                });
            } catch (JSONException e) {
            }

            dlg.setOnCancelListener(new AlertDialog.OnCancelListener() {
                public void onCancel(DialogInterface dialog) {
                    dialog.dismiss();
                    try {
                        result.put("buttonIndex", 0);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                    callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
                }
            });

            changeTextDirection(dlg);
        };
    };
    this.cordova.getActivity().runOnUiThread(runnable);
}

From source file:aerizostudios.com.cropshop.MainActivity.java

@Override
public void onMenuItemClick(View clickedView, int position) {

    if (position == 1) {

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

        LayoutInflater inflater = (LayoutInflater) getApplicationContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View v = inflater.inflate(R.layout.photo_quality, null);
        alert.setView(v);

        alert.setTitle("Select Photo Quality");
        alert.setPositiveButton("OKAY", new DialogInterface.OnClickListener() {
            @Override/*from   w w w . j a v  a 2s  . c  o  m*/
            public void onClick(DialogInterface dialog, int which) {

                if (normal.isChecked()) {
                    prefs = getSharedPreferences(prefName, MODE_PRIVATE);
                    SharedPreferences.Editor editor = prefs.edit();
                    editor.putInt("res", 300);
                    editor.commit();

                } else {
                    prefs = getSharedPreferences(prefName, MODE_PRIVATE);
                    SharedPreferences.Editor editor = prefs.edit();
                    editor.putInt("res", 400);
                    editor.commit();
                }

                prefs = getSharedPreferences(prefName, MODE_PRIVATE);
                quality = prefs.getInt("res", 0);

            }

        });
        alert.setNegativeButton("CANCEL", null);

        AlertD = alert.create();

        AlertD.show();
        normal = (RadioButton) AlertD.findViewById(R.id.normalQuality);
        high = (RadioButton) AlertD.findViewById(R.id.highQuality);

        Log.d("alert pref", "alert pref" + quality);

        if (quality == 300)
            normal.setChecked(true);
        else
            high.setChecked(true);
    }

    if (position == 2) {
        Uri uri = Uri.parse("market://details?id=" + getPackageName());
        Intent myAppLinkToMarket = new Intent(Intent.ACTION_VIEW, uri);
        try {
            startActivity(myAppLinkToMarket);
        } catch (ActivityNotFoundException e) {
            Toast.makeText(this, " unable to find market app", Toast.LENGTH_LONG).show();
        }
    }

    if (position == 3) {
        try {
            Intent i = new Intent(Intent.ACTION_SEND);
            i.setType("text/plain");
            i.putExtra(Intent.EXTRA_SUBJECT, "CROP SHOP");
            String sAux = "\nHey friends, Check out this COOL APP - CropShop - No Crop for Whatsapp and"
                    + " Instagram. This app helps you post images on Whatsapp and Instagram without any need "
                    + "of cropping them. It also adds Blur Effect to the Photos like Iphone and also"
                    + " Instagram filters." + "This app allows you to share the photos"
                    + " directly to Instagram,Facebook and Whatsapp from the App.\n"
                    + "Download this app from the play store.\n";
            sAux = sAux + "https://play.google.com/store/apps/details?id=aerizostudios.com.cropshop \n\n";
            i.putExtra(Intent.EXTRA_TEXT, sAux);
            startActivity(Intent.createChooser(i, "choose one"));
        } catch (Exception e) { //e.toString();
        }
    }

    if (position == 4) {
        startActivity(new Intent(this, Feedback.class));
    }
}