Example usage for android.text.method DigitsKeyListener DigitsKeyListener

List of usage examples for android.text.method DigitsKeyListener DigitsKeyListener

Introduction

In this page you can find the example usage for android.text.method DigitsKeyListener DigitsKeyListener.

Prototype

@Deprecated
public DigitsKeyListener() 

Source Link

Document

Allocates a DigitsKeyListener that accepts the ASCII digits 0 through 9.

Usage

From source file:Main.java

public static EditText applyNumericFilter(EditText field) {
    field.setKeyListener(new DigitsKeyListener());
    return field;
}

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);//  ww w . j a va  2 s.co m
    //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();
}