Example usage for android.widget EditText EditText

List of usage examples for android.widget EditText EditText

Introduction

In this page you can find the example usage for android.widget EditText EditText.

Prototype

public EditText(Context context) 

Source Link

Usage

From source file:edu.pitt.gis.uniapp.UniApp.java

/**
 * Create Custom title bar/*  w w w.ja  v a2 s .  c o  m*/
 * @return
 */
protected void createCustomTitleBar() {
    final UniApp me = this;

    if (this.customTitleSupported) {
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar);

        // Go to home
        final ImageButton homeBtn = (ImageButton) findViewById(R.id.appHomeBtn);
        homeBtn.setOnClickListener(new ImageButton.OnClickListener() {
            public void onClick(View v) {
                me.loadUrl(HOME_URL);
            }
        });

        // Input address
        final ImageButton urlBtn = (ImageButton) findViewById(R.id.appUrlBtn);
        urlBtn.setOnClickListener(new ImageButton.OnClickListener() {
            public void onClick(View v) {
                // Open input address dialog
                // Set an EditText view to get user input 
                final EditText input = new EditText(me);

                new AlertDialog.Builder(me).setTitle("Input URL").setMessage("Input URL to Load").setView(input)
                        .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int whichButton) {
                                Editable value = input.getText();
                                me.loadUrl(value.toString());
                            }
                        }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int whichButton) {
                                // Do nothing.
                            }
                        }).show();
            }
        });

        final ImageButton aboutBtn = (ImageButton) findViewById(R.id.aboutBtn);
        aboutBtn.setOnClickListener(new ImageButton.OnClickListener() {
            public void onClick(View v) {
                about.setTitle("About this app");
                about.show();
            }
        });
    }
}

From source file:com.dattasmoon.pebble.plugin.EditNotificationActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (Constants.IS_LOGGABLE) {
        Log.i(Constants.LOG_TAG, "Selected menu item id: " + String.valueOf(item.getItemId()));
    }//from w w w  . jav a2 s  .  c  om
    final AlertDialog.Builder builder = new AlertDialog.Builder(this);
    View v;
    ListViewHolder viewHolder;
    AdapterView.AdapterContextMenuInfo contextInfo;
    String app_name;
    final String package_name;
    switch (item.getItemId()) {
    case R.id.btnUncheckAll:

        builder.setTitle(R.string.dialog_confirm_title);
        builder.setMessage(getString(R.string.dialog_uncheck_message));
        builder.setCancelable(false);
        builder.setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int buttonId) {
                if (lvPackages == null || lvPackages.getAdapter() == null
                        || ((packageAdapter) lvPackages.getAdapter()).selected == null) {
                    //something went wrong
                    return;
                }
                ((packageAdapter) lvPackages.getAdapter()).selected.clear();
                lvPackages.invalidateViews();
            }
        });
        builder.setNegativeButton(R.string.decline, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int buttonId) {
                //do nothing!
            }
        });
        builder.setIcon(android.R.drawable.ic_dialog_alert);
        builder.show();

        return true;
    case R.id.btnSave:
        finish();
        return true;
    case R.id.btnDonate:
        Intent i = new Intent(Intent.ACTION_VIEW);
        i.setData(Uri.parse(Constants.DONATION_URL));
        startActivity(i);
        return true;
    case R.id.btnSettings:
        Intent settings = new Intent(this, SettingsActivity.class);
        startActivity(settings);
        return true;
    case R.id.btnRename:
        contextInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
        int position = contextInfo.position;
        long id = contextInfo.id;
        // the child view who's info we're viewing (should be equal to v)
        v = contextInfo.targetView;
        app_name = ((TextView) v.findViewById(R.id.tvPackage)).getText().toString();
        viewHolder = (ListViewHolder) v.getTag();
        if (viewHolder == null || viewHolder.chkEnabled == null) {
            //failure
            return true;
        }
        package_name = (String) viewHolder.chkEnabled.getTag();
        builder.setTitle(R.string.dialog_title_rename_notification);
        final EditText input = new EditText(this);
        input.setHint(app_name);
        builder.setView(input);
        builder.setPositiveButton(R.string.confirm, null);
        builder.setNegativeButton(R.string.decline, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                //do nothing
            }
        });
        final AlertDialog d = builder.create();
        d.setOnShowListener(new DialogInterface.OnShowListener() {
            @Override
            public void onShow(DialogInterface dialog) {
                Button b = d.getButton(AlertDialog.BUTTON_POSITIVE);
                if (b != null) {
                    b.setOnClickListener(new OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            //can't be nothing
                            if (input.getText().length() > 0) {
                                if (Constants.IS_LOGGABLE) {
                                    Log.i(Constants.LOG_TAG,
                                            "Adding rename for " + package_name + " to " + input.getText());
                                }
                                JSONObject rename = new JSONObject();
                                try {
                                    rename.put("pkg", package_name);
                                    rename.put("to", input.getText());
                                    arrayRenames.put(rename);
                                } catch (JSONException e) {
                                    e.printStackTrace();
                                }
                                ((packageAdapter) lvPackages.getAdapter()).notifyDataSetChanged();

                                d.dismiss();
                            } else {
                                input.setText(R.string.error_cant_be_blank);
                            }

                        }
                    });
                }
            }
        });

        d.show();

        return true;
    case R.id.btnRemoveRename:
        contextInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
        // the child view who's info we're viewing (should be equal to v)
        v = contextInfo.targetView;
        app_name = ((TextView) v.findViewById(R.id.tvPackage)).getText().toString();
        viewHolder = (ListViewHolder) v.getTag();
        if (viewHolder == null || viewHolder.chkEnabled == null) {
            if (Constants.IS_LOGGABLE) {
                Log.i(Constants.LOG_TAG, "Viewholder is null or chkEnabled is null");
            }
            //failure
            return true;
        }
        package_name = (String) viewHolder.chkEnabled.getTag();
        builder.setTitle(
                getString(R.string.dialog_title_remove_rename) + app_name + " (" + package_name + ")?");
        builder.setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                if (Constants.IS_LOGGABLE) {
                    Log.i(Constants.LOG_TAG, "Before remove is: " + String.valueOf(arrayRenames.length()));
                }
                JSONArray tmp = new JSONArray();
                try {
                    for (int i = 0; i < arrayRenames.length(); i++) {
                        if (!arrayRenames.getJSONObject(i).getString("pkg").equalsIgnoreCase(package_name)) {
                            tmp.put(arrayRenames.getJSONObject(i));
                        }
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                arrayRenames = tmp;
                if (Constants.IS_LOGGABLE) {
                    Log.i(Constants.LOG_TAG, "After remove is: " + String.valueOf(arrayRenames.length()));
                }
                ((packageAdapter) lvPackages.getAdapter()).notifyDataSetChanged();
            }
        });
        builder.setNegativeButton(R.string.decline, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                //do nothing
            }
        });
        builder.show();
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.powermonitor.epitech.ConfigModules.java

public void onbRenameClicked() {
    final EditText input = new EditText(getActivity());
    new AlertDialog.Builder(getActivity()).setTitle("Nouveau nom").setMessage("Entrez le nouveau nom")
            .setView(input).setPositiveButton("Ok", new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    doRename(input.getText().toString());
                }/*from  www  .j av  a2s .  c o  m*/
            }).setNegativeButton("Anuler", new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                }
            }).show();
}

From source file:org.apache.cordova.CordovaChromeClient.java

/**
 * Tell the client to display a prompt dialog to the user.
 * If the client returns true, WebView will assume that the client will
 * handle the prompt dialog and call the appropriate JsPromptResult method.
 *
 * Since we are hacking prompts for our own purposes, we should not be using them for
 * this purpose, perhaps we should hack console.log to do this instead!
 *
 * @param view//from   w  ww  .j ava  2  s .  co  m
 * @param url
 * @param message
 * @param defaultValue
 * @param result
 */
@Override
public boolean onJsPrompt(WebView view, String url, String message, String defaultValue,
        JsPromptResult result) {

    // Security check to make sure any requests are coming from the page initially
    // loaded in webview and not another loaded in an iframe.
    boolean reqOk = false;
    if (url.startsWith("file://") || Config.isUrlWhiteListed(url)) {
        reqOk = true;
    }

    // Calling PluginManager.exec() to call a native service using 
    // prompt(this.stringify(args), "gap:"+this.stringify([service, action, callbackId, true]));
    if (reqOk && defaultValue != null && defaultValue.length() > 3
            && defaultValue.substring(0, 4).equals("gap:")) {
        JSONArray array;
        try {
            array = new JSONArray(defaultValue.substring(4));
            String service = array.getString(0);
            String action = array.getString(1);
            String callbackId = array.getString(2);
            String r = this.appView.exposedJsApi.exec(service, action, callbackId, message);
            result.confirm(r == null ? "" : r);
        } catch (JSONException e) {
            e.printStackTrace();
            return false;
        }
    }

    // Sets the native->JS bridge mode. 
    else if (reqOk && defaultValue != null && defaultValue.equals("gap_bridge_mode:")) {
        try {
            this.appView.exposedJsApi.setNativeToJsBridgeMode(Integer.parseInt(message));
            result.confirm("");
        } catch (NumberFormatException e) {
            result.confirm("");
            e.printStackTrace();
        }
    }

    // Polling for JavaScript messages 
    else if (reqOk && defaultValue != null && defaultValue.equals("gap_poll:")) {
        String r = this.appView.exposedJsApi.retrieveJsMessages("1".equals(message));
        result.confirm(r == null ? "" : r);
    }

    // Do NO-OP so older code doesn't display dialog
    else if (defaultValue != null && defaultValue.equals("gap_init:")) {
        result.confirm("OK");
    }

    // Show dialog
    else {
        final JsPromptResult res = result;
        AlertDialog.Builder dlg = new AlertDialog.Builder(this.cordova.getActivity());
        dlg.setMessage(message);
        final EditText input = new EditText(this.cordova.getActivity());
        if (defaultValue != null) {
            input.setText(defaultValue);
        }
        dlg.setView(input);
        dlg.setCancelable(false);
        dlg.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                String usertext = input.getText().toString();
                res.confirm(usertext);
            }
        });
        dlg.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                res.cancel();
            }
        });
        dlg.show();
    }
    return true;
}

From source file:li.klass.fhem.adapter.devices.genericui.AvailableTargetStatesDialogUtil.java

public static <D extends FhemDevice<D>> TypeHandler<D> handlerForSelectedOption(D device, Context context,
        final String option, final TargetStateSelectedCallback callback) {

    SetList setList = device.getSetList();
    final SetListValue setListValue = setList.get(option);

    final DeviceStateRequiringAdditionalInformation specialDeviceState = DeviceStateRequiringAdditionalInformation
            .deviceStateForFHEM(option);

    if (setListValue instanceof SetListSliderValue) {
        final SetListSliderValue sliderValue = (SetListSliderValue) setListValue;
        return new TypeHandler<D>() {
            private int dimProgress = 0;

            @Override/* w  w  w . j  a  v a2  s  .c  o  m*/
            public View getContentViewFor(Context context, D device) {
                TableLayout tableLayout = new TableLayout(context);
                int initialProgress = 0;
                if (device instanceof DimmableDevice) {
                    initialProgress = ((DimmableDevice) device).getDimPosition();
                }

                tableLayout.addView(new DeviceDimActionRowFullWidth<D>(initialProgress, sliderValue.getStart(),
                        sliderValue.getStep(), sliderValue.getStop(), null,
                        R.layout.device_detail_seekbarrow_full_width) {

                    @Override
                    public void onStopDim(Context context, D device, int progress) {
                        dimProgress = progress;
                    }

                    @Override
                    public String toDimUpdateText(D device, int progress) {
                        return null;
                    }
                }.createRow(LayoutInflater.from(context), device));
                return tableLayout;
            }

            @Override
            public boolean onPositiveButtonClick(View view, Context context, D device) {
                callback.onTargetStateSelected(option, "" + dimProgress, device, context);
                return true;
            }
        };
    } else if (setListValue instanceof SetListGroupValue) {
        final SetListGroupValue groupValue = (SetListGroupValue) setListValue;
        final List<String> groupStates = groupValue.getGroupStates();
        return new TypeHandler<D>() {

            @Override
            public View getContentViewFor(final Context context, final D device) {
                ListView listView = new ListView(context);
                listView.setAdapter(
                        new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, groupStates));
                listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
                        String selection = groupStates.get(position);
                        callback.onTargetStateSelected(option, selection, device, context);
                        dialog.dismiss();
                    }
                });

                return listView;
            }

            @Override
            boolean requiresPositiveButton() {
                return false;
            }
        };
    } else if (specialDeviceState != null) {
        return new TypeHandler<D>() {

            private EditText editText;

            @Override
            public View getContentViewFor(Context context, D device) {
                editText = new EditText(context);
                return editText;
            }

            @Override
            public boolean onPositiveButtonClick(View view, Context context, D device) {
                Editable value = editText.getText();
                String text = value == null ? "" : value.toString();

                if (isValidAdditionalInformationValue(text, specialDeviceState)) {
                    callback.onTargetStateSelected(option, text, device, context);
                    return true;
                } else {
                    DialogUtil.showAlertDialog(context, R.string.error, R.string.invalidInput);
                    return false;
                }
            }
        };
    } else {
        callback.onTargetStateSelected(option, null, device, context);
        return null;
    }
}

From source file:com.rsltc.profiledata.main.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Button loginButton = (Button) findViewById(R.id.button);
    loginButton.setOnClickListener(new View.OnClickListener() {
        @Override/* w w w.  j av  a 2  s.  c o  m*/
        public void onClick(View v) {
            try {
                AlertDialog.Builder alert = new AlertDialog.Builder(thisActivity);
                alert.setTitle("Title here");

                StringBuilder query = new StringBuilder();

                query.append("redirect_uri=" + URLEncoder.encode(redirectUri, "utf-8"));
                query.append("&client_id=" + URLEncoder.encode(clientId, "utf-8"));
                query.append("&scope=" + URLEncoder.encode(scopes, "utf-8"));

                query.append("&response_type=code");
                URI uri = new URI("https://login.live.com/oauth20_authorize.srf?" + query.toString());

                URL url = uri.toURL();

                final WebView wv = new WebView(thisActivity);

                WebSettings webSettings = wv.getSettings();
                webSettings.setJavaScriptEnabled(true);
                wv.loadUrl(url.toString());
                wv.setWebViewClient(new WebViewClient() {
                    @Override
                    public boolean shouldOverrideUrlLoading(WebView view, String location) {
                        Log.e(TAG, location);
                        // TODO: extract to method
                        try {
                            URL url = new URL(location);

                            if (url.getPath().equalsIgnoreCase("/oauth20_desktop.srf")) {
                                System.out.println("Dit werkt al!");
                                System.out.println(url.getQuery());
                                Map<String, List<String>> result = splitQuery(url);
                                if (result.containsKey("code")) {
                                    System.out.println("bevat code");
                                    if (result.containsKey("error")) {
                                        System.out.println(String.format("{0}\r\n{1}", result.get("error"),
                                                result.get("errorDesc")));
                                    }
                                    System.out.println(result.get("code").get(0));
                                    String tokenError = GetToken(result.get("code").get(0), false);
                                    if (tokenError == null || "".equals(tokenError)) {
                                        System.out.println("Successful sign-in!");
                                        Log.e(TAG, "Successful sign-in!");
                                    } else {
                                        Log.e(TAG, "tokenError: " + tokenError);
                                    }
                                } else {
                                    System.out.println("Successful sign-out!");
                                }
                            }
                        } catch (IOException | URISyntaxException e) {
                            e.printStackTrace();
                        }

                        view.loadUrl(location);

                        return true;
                    }
                });
                LinearLayout linearLayout = new LinearLayout(thisActivity);
                linearLayout.setMinimumHeight(500);
                ArrayList<View> views = new ArrayList<View>();
                views.add(wv);
                linearLayout.addView(wv);
                EditText text = new EditText(thisActivity);
                text.setVisibility(View.GONE);
                linearLayout.addView(text);
                alert.setView(linearLayout);
                alert.setNegativeButton("Close", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.dismiss();
                    }
                });
                alert.show();
            } catch (Exception e) {
                Log.e(TAG, "dd");
            }
        }
    });
    Button showProfile = (Button) findViewById(R.id.button2);
    showProfile.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showProfile();
        }
    });
    Button showSummmary = (Button) findViewById(R.id.button3);
    showSummmary.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showSummaries();
        }
    });

    if (savedInstanceState != null)

    {
        authInProgress = savedInstanceState.getBoolean(AUTH_PENDING);
    }

    buildFitnessClient();
}

From source file:com.romanenco.gitt.BrowserActivity.java

/**
 * When pull from origin there are several case.
 * 1. We are in TAG (detached head): will inform user to
 * checkout a branch first./*  w  w  w.j a  v  a  2s. co  m*/
 * 2. Authentication required: ask for password (no passwd save).
 * 3. Anonymous user: just poll.
 */
private void pullFromOrigin() {
    if (current.getUserName() == null) {
        //no authentication required
        current.setState(Repo.State.Busy);
        DAO dao = new DAO(BrowserActivity.this);
        dao.open(true);
        dao.update(current);
        dao.close();
        Intent pull = new Intent(this, GitService.class);
        pull.putExtra(GitService.COMMAND, GitService.Command.Pull);
        pull.putExtra(GitService.REPO, current);
        startService(pull);
        Intent main = new Intent(this, MainActivity.class);
        main.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(main);
    } else {
        String req = getString(R.string.passwd_request, current.getUserName());
        final EditText passwd = new EditText(this);
        passwd.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
        AlertDialog dlg = new AlertDialog.Builder(this).setMessage(req)
                .setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        String password = passwd.getText().toString();
                        if (TextUtils.isEmpty(password)) {
                            pullFromOrigin();
                        } else {
                            current.setState(Repo.State.Busy);
                            DAO dao = new DAO(BrowserActivity.this);
                            dao.open(true);
                            dao.update(current);
                            dao.close();
                            Intent pull = new Intent(BrowserActivity.this, GitService.class);
                            pull.putExtra(GitService.COMMAND, GitService.Command.Pull);
                            pull.putExtra(GitService.REPO, current);
                            pull.putExtra(GitService.AUTH_PASSWD, password);
                            startService(pull);
                            Intent main = new Intent(BrowserActivity.this, MainActivity.class);
                            main.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                            startActivity(main);
                        }
                    }
                }).setNegativeButton(getString(android.R.string.cancel), null).create();
        dlg.setCanceledOnTouchOutside(false);
        dlg.setView(passwd);
        dlg.show();
    }

}

From source file:com.packetsender.android.MainActivity.java

public AdapterView.OnItemClickListener getTrafficOnClick() {

    final MainActivity Main = this;

    return new AdapterView.OnItemClickListener() {

        @Override/*from  w ww.ja v  a  2  s.  c  o  m*/
        public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {
            final int finalPosition = position;
            Log.d("main", DataStorage.FILE_LINE("Clicked " + position));
            final Packet updatePacket = trafficLogPackets.get(position).duplicate();

            updatePacket.name = "save";
            AlertDialog.Builder alert = new AlertDialog.Builder(Main);
            alert.setTitle("Packet Name?");

            // Set an EditText view to get user input
            final EditText input = new EditText(Main);

            input.setInputType(InputType.TYPE_CLASS_TEXT); //);
            alert.setView(input);

            alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    String value = input.getText().toString();
                    // Do something with value!
                    updatePacket.name = value;

                    Packet tempPacket = updatePacket;
                    updatePacket.port = tempPacket.fromPort;
                    updatePacket.toIP = tempPacket.fromIP;

                    ////mDBHelper.updatePacket(packet);
                    //mDBHelper.storemessage(packet);
                    dataStore.savePacket(updatePacket);
                    updateSavedPacketsList(packetsFragmentView);

                    Toast.makeText(mContext, "Reversed addresses and saved.", Toast.LENGTH_SHORT).show();
                }
            });

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

            alert.show();
            // see http://androidsnippets.com/prompt-user-input-with-an-alertdialog

        }

    };

}

From source file:org.apache.cordova.AndroidChromeClient.java

/**
 * Tell the client to display a prompt dialog to the user.
 * If the client returns true, WebView will assume that the client will
 * handle the prompt dialog and call the appropriate JsPromptResult method.
 *
 * Since we are hacking prompts for our own purposes, we should not be using them for
 * this purpose, perhaps we should hack console.log to do this instead!
 *
 * @param view//from  ww w  .j  av  a 2s. c  o  m
 * @param url
 * @param message
 * @param defaultValue
 * @param result
 */
@Override
public boolean onJsPrompt(WebView view, String url, String message, String defaultValue,
        JsPromptResult result) {

    // Security check to make sure any requests are coming from the page initially
    // loaded in webview and not another loaded in an iframe.
    boolean reqOk = false;
    if (url.startsWith("file://") || Config.isUrlWhiteListed(url)) {
        reqOk = true;
    }

    // Calling PluginManager.exec() to call a native service using 
    // prompt(this.stringify(args), "gap:"+this.stringify([service, action, callbackId, true]));
    if (reqOk && defaultValue != null && defaultValue.length() > 3
            && defaultValue.substring(0, 4).equals("gap:")) {
        JSONArray array;
        try {
            array = new JSONArray(defaultValue.substring(4));
            String service = array.getString(0);
            String action = array.getString(1);
            String callbackId = array.getString(2);

            //String r = this.appView.exposedJsApi.exec(service, action, callbackId, message);
            String r = this.appView.exec(service, action, callbackId, message);
            result.confirm(r == null ? "" : r);
        } catch (JSONException e) {
            e.printStackTrace();
            return false;
        }
    }

    // Sets the native->JS bridge mode. 
    else if (reqOk && defaultValue != null && defaultValue.equals("gap_bridge_mode:")) {
        try {
            //this.appView.exposedJsApi.setNativeToJsBridgeMode(Integer.parseInt(message));
            this.appView.setNativeToJsBridgeMode(Integer.parseInt(message));
            result.confirm("");
        } catch (NumberFormatException e) {
            result.confirm("");
            e.printStackTrace();
        }
    }

    // Polling for JavaScript messages 
    else if (reqOk && defaultValue != null && defaultValue.equals("gap_poll:")) {
        //String r = this.appView.exposedJsApi.retrieveJsMessages("1".equals(message));
        String r = this.appView.retrieveJsMessages("1".equals(message));
        result.confirm(r == null ? "" : r);
    }

    // Do NO-OP so older code doesn't display dialog
    else if (defaultValue != null && defaultValue.equals("gap_init:")) {
        result.confirm("OK");
    }

    // Show dialog
    else {
        final JsPromptResult res = result;
        AlertDialog.Builder dlg = new AlertDialog.Builder(this.cordova.getActivity());
        dlg.setMessage(message);
        final EditText input = new EditText(this.cordova.getActivity());
        if (defaultValue != null) {
            input.setText(defaultValue);
        }
        dlg.setView(input);
        dlg.setCancelable(false);
        dlg.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                String usertext = input.getText().toString();
                res.confirm(usertext);
            }
        });
        dlg.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                res.cancel();
            }
        });
        dlg.create();
        dlg.show();
    }
    return true;
}

From source file:com.android.mms.rcs.FavoriteDetailActivity.java

private void inputNumberForwarMessage() {
    final EditText editText = new EditText(FavoriteDetailActivity.this);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    editText.setLayoutParams(lp);/*from   w  w  w .jav a  2s .co  m*/
    editText.setInputType(InputType.TYPE_CLASS_PHONE);
    editText.setHint(R.string.forward_input_number_hint);
    new AlertDialog.Builder(FavoriteDetailActivity.this).setTitle(R.string.forward_input_number_title)
            .setView(editText).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    String input = editText.getText().toString();
                    if (TextUtils.isEmpty(input)) {
                        Toast.makeText(FavoriteDetailActivity.this, R.string.forward_input_number_title,
                                Toast.LENGTH_SHORT).show();
                    } else {
                        String[] numbers = input.split(";");
                        if (numbers != null && numbers.length > 0) {
                            ArrayList<String> numberList = new ArrayList<String>();
                            for (int i = 0; i < numbers.length; i++) {
                                numberList.add(numbers[i]);
                            }
                            forwardRcsMessage(numberList);
                        }
                    }
                }
            }).setNegativeButton(android.R.string.cancel, null).show();
}