How to change the input method of an Edit text in java?

1

Hi, I am programming in android studio and I need to know how to change the input method (inputType) of an Edit text with java code, not from xml.

public void button (View view){
    TableLayout table = (TableLayout) findViewById(R.id.table);

    TableRow tableRow = new TableRow(this);
    table.addView(tableRow);

    EditText fecha = new EditText(this);
    EditText monto = new EditText(this);

    fecha.setFilters(new InputFilter[] { new InputFilter.LengthFilter(8)});
    monto.setFilters(new InputFilter[] { new InputFilter.LengthFilter(5)});

    //aca quiero indicar el metodo InputType del editText pero no me sale al 
    //hacer fecha.

    tableRow.addView(fecha);
    tableRow.addView(monto);
    
asked by Lucho Juniors 15.08.2017 в 20:19
source

1 answer

2

The .setInputType() function allows you to assign the type of the input method in an EditText.

Here is an example to assign the input mode of a password to a EditText called editPass:

editPass.setInputType(TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);

Here is a link to the Android documentation where you have all the method types input you can assign.

    
answered by 16.08.2017 / 22:13
source