Example usage for android.text InputType TYPE_CLASS_NUMBER

List of usage examples for android.text InputType TYPE_CLASS_NUMBER

Introduction

In this page you can find the example usage for android.text InputType TYPE_CLASS_NUMBER.

Prototype

int TYPE_CLASS_NUMBER

To view the source code for android.text InputType TYPE_CLASS_NUMBER.

Click Source Link

Document

Class for numeric text.

Usage

From source file:com.sigilance.CardEdit.MainActivity.java

private void promptForChangePin(final int mode) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    if (mode == 0x83)
        builder.setTitle(R.string.action_change_pw3);
    else//  ww  w  .j  a  v  a 2s .c  o  m
        builder.setTitle(R.string.action_change_pw1);

    final String typeString = mode == 0x83 ? "Admin" : "User";
    String defaultString = mode == 0x83 ? "12345678" : "123456";
    builder.setMessage(String.format("REMINDER: The default %s PIN is %s", typeString, defaultString));
    final EditText oldPinInput = new EditText(this);
    oldPinInput.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD);
    oldPinInput.setHint(String.format("Old %s PIN", mode == 0x83 ? "Admin" : "User"));
    final EditText newPinInput = new EditText(this);
    newPinInput.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD);
    newPinInput.setHint(String.format("New %s PIN", mode == 0x83 ? "Admin" : "User"));
    final EditText confirmPinInput = new EditText(this);
    confirmPinInput.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD);
    confirmPinInput.setHint("Repeat New PIN");
    LinearLayout fields = new LinearLayout(this);
    fields.setOrientation(LinearLayout.VERTICAL);
    fields.addView(oldPinInput);
    fields.addView(newPinInput);
    fields.addView(confirmPinInput);
    builder.setView(fields);

    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            // Placeholder; we will override this
        }
    });
    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });

    final AlertDialog dialog = builder.create();
    dialog.show();
    dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (oldPinInput.getText().toString().length() == 0
                    || newPinInput.getText().toString().length() == 0) {
                Toast.makeText(MainActivity.this, "Enter a PIN!", Toast.LENGTH_SHORT).show();
                return;
            }
            if (!(confirmPinInput.getText().toString().equals(newPinInput.getText().toString()))) {
                newPinInput.setText("");
                confirmPinInput.setText("");
                Toast.makeText(MainActivity.this, "PINs did not match.", Toast.LENGTH_SHORT).show();
                return;
            }
            int minPinLength = (mode == 0x83) ? 8 : 6;
            if (oldPinInput.getText().toString().length() < minPinLength
                    || newPinInput.getText().toString().length() < minPinLength) {
                newPinInput.setText("");
                confirmPinInput.setText("");
                Toast.makeText(MainActivity.this,
                        String.format("%s PIN must be at least %d digits.", typeString, minPinLength),
                        Toast.LENGTH_SHORT).show();
                return;
            }
            // Once we have valid PINs, add the pending operation.
            mPendingOperations.add(new PendingChangePinOperation(mode, oldPinInput.getText().toString(),
                    newPinInput.getText().toString()));
            // And prompt the user to change the PIN.
            hideUi();
            findTextViewById(R.id.id_action_reqiured_warning).setText(R.string.warning_tap_card_to_change);
            dialog.dismiss();
        }
    });
}

From source file:nya.miku.wishmaster.api.AbstractChanModule.java

/**
 *     ( ?/ )   ? ?-?//from   ww w  .ja  va  2 s. c o  m
 * @param group ,   ??? 
 */
protected void addProxyPreferences(PreferenceGroup group) {
    final Context context = group.getContext();
    PreferenceCategory proxyCat = new PreferenceCategory(context); //? ? ?
    proxyCat.setTitle(R.string.pref_cat_proxy);
    group.addPreference(proxyCat);
    CheckBoxPreference useProxyPref = new CheckBoxPreference(context); //? "?  ? "
    useProxyPref.setTitle(R.string.pref_use_proxy);
    useProxyPref.setSummary(R.string.pref_use_proxy_summary);
    useProxyPref.setKey(getSharedKey(PREF_KEY_USE_PROXY));
    useProxyPref.setDefaultValue(false);
    useProxyPref.setOnPreferenceChangeListener(updateHttpListener);
    proxyCat.addPreference(useProxyPref);
    EditTextPreference proxyHostPref = new EditTextPreference(context); //  ? ?-?
    proxyHostPref.setTitle(R.string.pref_proxy_host);
    proxyHostPref.setDialogTitle(R.string.pref_proxy_host);
    proxyHostPref.setSummary(R.string.pref_proxy_host_summary);
    proxyHostPref.setKey(getSharedKey(PREF_KEY_PROXY_HOST));
    proxyHostPref.setDefaultValue(DEFAULT_PROXY_HOST);
    proxyHostPref.getEditText().setSingleLine();
    proxyHostPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
    proxyHostPref.setOnPreferenceChangeListener(updateHttpListener);
    proxyCat.addPreference(proxyHostPref);
    proxyHostPref.setDependency(getSharedKey(PREF_KEY_USE_PROXY));
    EditTextPreference proxyHostPort = new EditTextPreference(context); //   ?-?
    proxyHostPort.setTitle(R.string.pref_proxy_port);
    proxyHostPort.setDialogTitle(R.string.pref_proxy_port);
    proxyHostPort.setSummary(R.string.pref_proxy_port_summary);
    proxyHostPort.setKey(getSharedKey(PREF_KEY_PROXY_PORT));
    proxyHostPort.setDefaultValue(DEFAULT_PROXY_PORT);
    proxyHostPort.getEditText().setSingleLine();
    proxyHostPort.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER);
    proxyHostPort.setOnPreferenceChangeListener(updateHttpListener);
    proxyCat.addPreference(proxyHostPort);
    proxyHostPort.setDependency(getSharedKey(PREF_KEY_USE_PROXY));
}

From source file:com.eugene.fithealthmaingit.UI.ManualEntrySaveMealFragment.java

private void updateItems() {
    mToolbar.setNavigationIcon(R.mipmap.ic_arrow_back);
    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override/*from   w w w.  ja va 2 s  . com*/
        public void onClick(View v) {
            Intent intent = new Intent(getActivity(), ChooseAddMealActivity.class);
            intent.putExtra(Globals.MEAL_TYPE, mealType);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);
        }
    });
    mToolbar.inflateMenu(R.menu.menu_user_info);
    mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            if (menuItem.getItemId() == R.id.action_save)
                saveMeal();
            return false;
        }
    });
    mServingSizeUpdated.setText("1");

    LinearLayout changeServing = (LinearLayout) v.findViewById(R.id.changeServing);
    changeServing.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());

            alert.setTitle("Update Serving Size: ");
            alert.setMessage("Servings Consumed");

            final EditText input = new EditText(getActivity());
            input.setText(mServingg.getText().toString());
            input.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
            input.selectAll();
            input.setGravity(Gravity.CENTER_HORIZONTAL);
            alert.setView(input, 64, 0, 64, 0);
            alert.setPositiveButton("Update", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    double values = Double.valueOf(input.getText().toString());
                    mServingg.setText(df.format(values));
                    mServingSizeUpdated.setText(df.format(values));
                    mCalUpdate.setText(dfW.format(Double.valueOf(mCalories) * values));
                    mCalorieProgress = Double.valueOf(mCalories) * values;
                    mFattieUpdate.setText(df.format(Double.valueOf(mFat) * values));
                    mFatProgress = Double.valueOf(mFat) * values;
                    mSaturatedFatUpdate.setText(df.format(Double.valueOf(mSaturatedFat) * values));
                    mCholesterolUpdate.setText(df.format(Double.valueOf(mCholesterol) * values));
                    mSodiumUpdate.setText(df.format(Double.valueOf(mSodium) * values));
                    mCarbUpdate.setText(df.format(Double.valueOf(mCarbohydrates) * values));
                    mCarbProgress = Double.valueOf(mCarbohydrates) * values;
                    mFiberUpdate.setText(df.format(Double.valueOf(mFiber) * values));
                    mSugarUpdate.setText(df.format(Double.valueOf(mSugar) * values));
                    mProUpdate.setText(df.format(Double.valueOf(mProtein) * values));
                    mProteinProgress = Double.valueOf(mProtein) * values;
                    mVitAUpdate.setText(df.format(Double.valueOf(mVitA) * values));
                    mVitCUpdate.setText(df.format(Double.valueOf(mVitC) * values));
                    mCalciumUpdate.setText(df.format(Double.valueOf(mCalcium) * values));
                    mIronUpdate.setText(df.format(Double.valueOf(mIron) * values));
                    progressBars();
                    ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE))
                            .hideSoftInputFromWindow(input.getWindowToken(), 0);
                }
            });

            alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE))
                            .hideSoftInputFromWindow(input.getWindowToken(), 0);
                }
            });
            alert.setCancelable(false);
            alert.show();
            ((InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE))
                    .toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_NOT_ALWAYS);
        }
    });

}

From source file:com.tozny.e3db.android.DefaultKeyAuthenticator.java

@Override
public void getPassword(final PasswordHandler handler) {
    this.activity.runOnUiThread(new Runnable() {
        @Override//from   ww  w  . jav  a2  s  . com
        public void run() {
            Context ctx = DefaultKeyAuthenticator.this.activity;

            final EditText input = new EditText(ctx);
            input.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD);

            new AlertDialog.Builder(DefaultKeyAuthenticator.this.activity)
                    .setMessage(ctx.getString(R.string.key_provider_please_enter_pin))
                    .setPositiveButton(ctx.getString(R.string.key_provider_ok),
                            new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialogInterface, int i) {
                                    try {
                                        handler.handlePassword(input.getText().toString());

                                    } catch (UnrecoverableKeyException e) {
                                        wrongPasswordCount[0]++;

                                        if (wrongPasswordCount[0] >= 3) {
                                            handler.handleError(
                                                    new RuntimeException("Too many password tries."));
                                        } else {
                                            Toast.makeText(DefaultKeyAuthenticator.this.activity,
                                                    e.getMessage(), Toast.LENGTH_SHORT).show();
                                            getPassword(handler);
                                        }
                                    }
                                }
                            })
                    .setNegativeButton(ctx.getString(R.string.key_provider_cancel),
                            new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialogInterface, int i) {
                                    handler.handleCancel();
                                }
                            })
                    .setView(input).show();

            input.setOnFocusChangeListener(new View.OnFocusChangeListener() {
                @Override
                public void onFocusChange(View view, boolean b) {
                    if (input.isEnabled() && input.isFocusable()) {
                        input.post(new Runnable() {
                            @Override
                            public void run() {
                                final InputMethodManager imm = (InputMethodManager) DefaultKeyAuthenticator.this.activity
                                        .getSystemService(Context.INPUT_METHOD_SERVICE);
                                imm.showSoftInput(input, InputMethodManager.SHOW_IMPLICIT);
                            }
                        });
                    }
                }
            });
        }
    });
}

From source file:es.ugr.swad.swadroid.modules.tests.TestsMake.java

/**
 * Shows a test question on screen//from ww w. j  a  va2 s  .c  o  m
 *
 * @param pos Question's position in questions's list of the test
 */
private void showQuestion(int pos) {
    TestQuestion question = test.getQuestions().get(pos);
    List<TestAnswer> answers = question.getAnswers();
    TestAnswer a;
    ScrollView scrollContent = (ScrollView) findViewById(R.id.testMakeScroll);
    LinearLayout testMakeList = (LinearLayout) findViewById(R.id.testMakeList);
    TextView stem = (TextView) findViewById(R.id.testMakeQuestionStem);
    TextView questionFeedback = (TextView) findViewById(R.id.testMakeQuestionFeedback);
    TextView answerFeedback = (TextView) findViewById(R.id.testMakeAnswerFeedback);
    TextView score = (TextView) findViewById(R.id.testMakeQuestionScore);
    TextView textCorrectAnswer = (TextView) findViewById(R.id.testMakeCorrectAnswer);
    EditText textAnswer = (EditText) findViewById(R.id.testMakeEditText);
    ImageView img = (ImageView) findViewById(R.id.testMakeCorrectAnswerImage);
    MenuItem actionScoreItem = menu.findItem(R.id.action_score);
    CheckedAnswersArrayAdapter checkedAnswersAdapter;
    String answerType = question.getAnswerType();
    String feedback = test.getFeedback();
    String questionFeedbackText = question.getFeedback();
    String correctAnswer = "";
    int numAnswers = answers.size();
    Float questionScore;
    DecimalFormat df = new DecimalFormat("0.00");
    int feedbackLevel;
    int mediumFeedbackLevel = Test.FEEDBACK_VALUES.indexOf(Test.FEEDBACK_MEDIUM);
    int maxFeedbackLevel = Test.FEEDBACK_VALUES.indexOf(Test.FEEDBACK_MAX);

    scrollContent.setOnTouchListener(new View.OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            findViewById(R.id.testMakeList).getParent().requestDisallowInterceptTouchEvent(false);
            return false;
        }
    });
    testMakeList.setOnTouchListener(new View.OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            // Disallow the touch request for parent scroll on touch of child view
            v.getParent().requestDisallowInterceptTouchEvent(true);
            return false;
        }
    });

    questionFeedback.setVisibility(View.GONE);
    answerFeedback.setVisibility(View.GONE);
    textAnswer.setVisibility(View.GONE);
    textCorrectAnswer.setVisibility(View.GONE);
    testMakeList.setVisibility(View.GONE);
    img.setVisibility(View.GONE);

    testMakeList.removeAllViews();
    stem.setText(Html.fromHtml(question.getStem()));

    if ((questionFeedbackText != null) && (!questionFeedbackText.equals(Constants.NULL_VALUE))) {
        questionFeedback.setText(Html.fromHtml(questionFeedbackText));
    }

    feedbackLevel = Test.FEEDBACK_VALUES.indexOf(feedback);

    if (test.isEvaluated() && (feedbackLevel == maxFeedbackLevel)
            && !question.getFeedback().equals(Constants.NULL_VALUE)) {
        questionFeedback.setVisibility(View.VISIBLE);
    } else {
        questionFeedback.setVisibility(View.GONE);
    }

    if (answerType.equals(TestAnswer.TYPE_TEXT) || answerType.equals(TestAnswer.TYPE_INT)
            || answerType.equals(TestAnswer.TYPE_FLOAT)) {

        if (answerType.equals(TestAnswer.TYPE_INT)) {
            textAnswer.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED);
        } else if (answerType.equals(TestAnswer.TYPE_FLOAT)) {
            textAnswer.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL
                    | InputType.TYPE_NUMBER_FLAG_SIGNED);
        } else {
            textAnswer.setInputType(InputType.TYPE_CLASS_TEXT);
        }

        a = answers.get(0);
        textAnswer.setText(a.getUserAnswer());
        textAnswer.setVisibility(View.VISIBLE);

        answerFeedback.setText(Html.fromHtml(a.getFeedback()));

        if (test.isEvaluated() && (feedbackLevel > mediumFeedbackLevel)) {
            if (answerType.equals(TestAnswer.TYPE_FLOAT)) {
                correctAnswer = "[" + a.getAnswer() + ";" + answers.get(1).getAnswer() + "]";

                if ((feedbackLevel == maxFeedbackLevel) && !a.getFeedback().equals(Constants.NULL_VALUE)) {
                    answerFeedback.setVisibility(View.VISIBLE);
                } else {
                    answerFeedback.setVisibility(View.GONE);
                }
            } else {
                for (int i = 0; i < numAnswers; i++) {
                    a = answers.get(i);

                    if ((feedbackLevel == maxFeedbackLevel) && !a.getFeedback().equals(Constants.NULL_VALUE)) {
                        correctAnswer += "<strong>" + a.getAnswer() + "</strong><br/>";
                        correctAnswer += "<i>" + a.getFeedback() + "</i><br/><br/>";
                    } else {
                        correctAnswer += a.getAnswer() + "<br/>";
                    }
                }
            }

            textCorrectAnswer.setText(Html.fromHtml(correctAnswer));
            textCorrectAnswer.setVisibility(View.VISIBLE);
        }
    } else if (answerType.equals(TestAnswer.TYPE_MULTIPLE_CHOICE)) {
        checkedAnswersAdapter = new CheckedAnswersArrayAdapter(this, R.layout.list_item_multiple_choice,
                answers, test.isEvaluated(), test.getFeedback(), answerType);

        for (int i = 0; i < numAnswers; i++) {
            a = answers.get(i);
            CheckableLinearLayout item = (CheckableLinearLayout) checkedAnswersAdapter.getView(i, null, null);
            item.setChecked(Utils.parseStringBool(a.getUserAnswer()));
            testMakeList.addView(item);
        }

        testMakeList.setVisibility(View.VISIBLE);
    } else {
        if (answerType.equals(TestAnswer.TYPE_TRUE_FALSE) && (numAnswers < 2)) {
            if (answers.get(0).getAnswer().equals(TestAnswer.VALUE_TRUE)) {
                answers.add(1,
                        new TestAnswer(0, 1, 0, false, TestAnswer.VALUE_FALSE, answers.get(0).getFeedback()));
            } else {
                answers.add(0,
                        new TestAnswer(0, 0, 0, false, TestAnswer.VALUE_TRUE, answers.get(0).getFeedback()));
            }

            numAnswers = 2;
        }

        checkedAnswersAdapter = new CheckedAnswersArrayAdapter(this, R.layout.list_item_single_choice, answers,
                test.isEvaluated(), test.getFeedback(), answerType);

        for (int i = 0; i < numAnswers; i++) {
            a = answers.get(i);
            CheckableLinearLayout item = (CheckableLinearLayout) checkedAnswersAdapter.getView(i, null, null);
            item.setChecked(a.getAnswer().equals(answers.get(0).getUserAnswer()));
            testMakeList.addView(item);
        }

        testMakeList.setVisibility(View.VISIBLE);
    }

    if (test.isEvaluated() && (feedbackLevel > mediumFeedbackLevel)) {
        textAnswer.setEnabled(false);
        textAnswer.setOnClickListener(null);

        if (feedback.equals(Test.FEEDBACK_HIGH)) {
            img.setImageResource(R.drawable.btn_check_buttonless_on);
            if (!answerType.equals(TestAnswer.TYPE_TRUE_FALSE)
                    && !answerType.equals(TestAnswer.TYPE_MULTIPLE_CHOICE)
                    && !answerType.equals(TestAnswer.TYPE_UNIQUE_CHOICE)) {

                if (!answers.get(0).isCorrectAnswered()) {
                    img.setImageResource(android.R.drawable.ic_delete);
                }

                img.setVisibility(View.VISIBLE);
            }
        }

        questionScore = test.getQuestionScore(pos);
        if (questionScore > 0) {
            score.setTextColor(getResources().getColor(R.color.green));
        } else if (questionScore < 0) {
            score.setTextColor(getResources().getColor(R.color.red));
        } else {
            score.setTextColor(Color.BLACK);
        }

        score.setText(df.format(questionScore));

        MenuItemCompat.setActionView(actionScoreItem, score);
        actionScoreItem.setVisible(true);
    }
}

From source file:com.ichi2.anki.ModelFieldEditor.java

private void repositionFieldDialog() {
    mFieldNameInput = new EditText(this);
    mFieldNameInput.setRawInputType(InputType.TYPE_CLASS_NUMBER);
    new MaterialDialog.Builder(this)
            .title(String.format(getResources().getString(R.string.model_field_editor_reposition), 1,
                    mFieldLabels.size()))
            .positiveText(R.string.dialog_ok).customView(mFieldNameInput, true)
            .callback(new MaterialDialog.ButtonCallback() {
                @Override// w  ww  .j  ava  2 s.co m
                public void onPositive(MaterialDialog dialog) {
                    String newPosition = mFieldNameInput.getText().toString();
                    int pos;
                    try {
                        pos = Integer.parseInt(newPosition);
                    } catch (NumberFormatException n) {
                        showToast(getResources().getString(R.string.toast_out_of_range));
                        return;
                    }

                    if (pos < 1 || pos > mFieldLabels.size()) {
                        showToast(getResources().getString(R.string.toast_out_of_range));
                    } else {
                        // Input is valid, now attempt to modify
                        try {
                            mCol.modSchema();
                            DeckTask.launchDeckTask(DeckTask.TASK_TYPE_REPOSITION_FIELD, mChangeFieldHandler,
                                    new DeckTask.TaskData(new Object[] { mMod,
                                            mNoteFields.getJSONObject(mCurrentPos), pos - 1 }));
                        } catch (ConfirmModSchemaException e) {

                            // Handle mod schema confirmation
                            ConfirmationDialog c = new ConfirmationDialog() {
                                public void confirm() {
                                    try {
                                        mCol.modSchemaNoCheck();
                                        String newPosition = mFieldNameInput.getText().toString();
                                        int pos = Integer.parseInt(newPosition);
                                        DeckTask.launchDeckTask(DeckTask.TASK_TYPE_REPOSITION_FIELD,
                                                mChangeFieldHandler, new DeckTask.TaskData(new Object[] { mMod,
                                                        mNoteFields.getJSONObject(mCurrentPos), pos - 1 }));
                                        dismissContextMenu();
                                    } catch (JSONException e) {
                                        throw new RuntimeException(e);
                                    }
                                }

                                public void cancel() {
                                    dismissContextMenu();
                                }
                            };
                            c.setArgs(getResources().getString(R.string.full_sync_confirmation));
                            ModelFieldEditor.this.showDialogFragment(c);
                        } catch (JSONException e) {
                            throw new RuntimeException(e);
                        }
                    }
                }
            }).negativeText(R.string.dialog_cancel).show();
}

From source file:com.citrus.sample.WalletPaymentFragment.java

private void showPrompt(final Utils.PaymentType paymentType) {
    final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    String message = null;//ww  w .j ava2 s. c  o  m
    String positiveButtonText = null;

    switch (paymentType) {
    case LOAD_MONEY:
    case AUTO_LOAD_MONEY:
        message = "Please enter the amount to load.";
        positiveButtonText = "Load Money";
        break;
    case CITRUS_CASH:
    case NEW_CITRUS_CASH:
        message = "Please enter the transaction amount.";
        positiveButtonText = "Pay";
        break;
    case PG_PAYMENT:
    case NEW_PG_PAYMENT:
    case WALLET_PG_PAYMENT:
        message = "Please enter the transaction amount.";
        positiveButtonText = "Make Payment";
        break;
    }

    LinearLayout linearLayout = new LinearLayout(getActivity());
    linearLayout.setOrientation(LinearLayout.VERTICAL);

    alert.setTitle("Transaction Amount?");
    alert.setMessage(message);
    // Set an EditText view to get user input
    final EditText input = new EditText(getActivity());
    input.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
    alert.setView(input);
    alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            String value = input.getText().toString();

            mListener.onPaymentTypeSelected(paymentType, new Amount(value));

            input.clearFocus();
            // Hide the keyboard.
            InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(input.getWindowToken(), 0);
        }
    });

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

    input.requestFocus();
    alert.show();
}

From source file:com.sigilance.CardEdit.MainActivity.java

private void promptForVerifyPin(final int mode) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.action_enable_edit_mode);
    builder.setMessage(// w  w  w . j  a  va  2 s .  co  m
            "Enter the Admin PIN to edit data on the card.\nREMINDER: The default Admin PIN is 12345678");
    final EditText input = new EditText(this);
    input.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD);
    builder.setView(input);

    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (input.getText().toString().length() == 0) {
                Toast.makeText(MainActivity.this, "Enter a PIN!", Toast.LENGTH_SHORT).show();
                return;
            }
            int minPinLength = (mode == 0x83) ? 8 : 6;
            if (input.getText().toString().length() < minPinLength) {
                input.setText("");
                Toast.makeText(MainActivity.this, String.format("PIN is at least %d digits.", minPinLength),
                        Toast.LENGTH_SHORT).show();
                return;
            }
            mPendingOperations.add(new PendingVerifyPinOperation(mode, input.getText().toString()));
            hideUi();
            findTextViewById(R.id.id_action_reqiured_warning).setText(R.string.warning_tap_card_to_verify);
        }
    });
    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });

    builder.create().show();
}

From source file:com.duy.pascal.ui.editor.EditorActivity.java

@Override
public void goToLine() {
    EditorFragment editorFragment = mPagerAdapter.getCurrentFragment();
    if (editorFragment != null) {
        int lineCount = editorFragment.getEditor().getLineCount();
        String hint = String.format(Locale.US, "0-%d", lineCount);
        UIUtils.showInputDialog(this, getString(R.string.goto_line), hint, null, InputType.TYPE_CLASS_NUMBER,
                new UIUtils.OnShowInputCallback() {
                    @Override//from  www.j a  va 2s  .  com
                    public void onConfirm(CharSequence input) {
                        String line = input.toString();
                        if (!line.isEmpty()) {
                            EditorFragment editorFragment = mPagerAdapter.getCurrentFragment();
                            if (editorFragment != null) {
                                try {
                                    int lineNumber = Integer.parseInt(line);
                                    editorFragment.goToLine(lineNumber);
                                } catch (NumberFormatException ignored) {
                                }
                            }
                        }
                    }
                });
    }
}

From source file:me.kaidul.uhunt.MainActivity.java

void ProblemNoPicker(final int requestCode) {
    final EditText input = new EditText(this);
    input.setInputType(InputType.TYPE_CLASS_NUMBER);
    new AlertDialog.Builder(this).setTitle("Enter problem Id").setView(input)
            .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();/*from  w  w  w  . j a  v  a 2 s .c  o  m*/
                }
            }).setPositiveButton("OK", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    String str = input.getEditableText().toString();
                    if (str.equals("")) {
                        new AlertDialog.Builder(MainActivity.this).setTitle("Invalid Problem No")
                                .setMessage("Please Enter a valid problem no.!")
                                .setNeutralButton("OK", new DialogInterface.OnClickListener() {

                                    public void onClick(DialogInterface dlg, int sumthin) {
                                        ProblemNoPicker(requestCode);
                                    }
                                }).show();
                        return;
                    }
                    problemNo = Integer.parseInt(str);
                    if (requestCode == 1) {
                        ProblemWebView searchProblem = (ProblemWebView) getSupportFragmentManager()
                                .findFragmentById(R.id.content_frame);
                        if (searchProblem != null) {
                            searchProblem.updateUrl(problemNo);
                        }
                    } else if (requestCode == 2) {
                        ProblemStatistics problemStatistics = (ProblemStatistics) getSupportFragmentManager()
                                .findFragmentById(R.id.content_frame);
                        if (problemStatistics != null) {
                            problemStatistics.updateUrl(problemNo);
                        }
                    }
                }
            }).show();
}