-2

is it possible to set a value into a editable edittext like this?

LayoutInflater layoutInflater = LayoutInflater.from(getBaseContext());
    View promptView = layoutInflater.inflate(R.layout.prompt_dialog, null);

    final EditText input = (EditText) promptView.findViewById(R.id.input_prompt);
    TextView txt_prompt_mensaje = (TextView) promptView.findViewById(R.id.txt_prompt_mensaje);

    Editable value = input.getText();

    int suma_valor = Integer.parseInt(value.toString());
    suma_valor = suma_valor + Integer.parseInt(value.toString());
    Log.d("#### suma valor", Integer.toString(suma_valor));
    input.setText(Integer.toString(suma_valor));

1 Answers1

0

Using input.setText("Testing"); will give the editText the string of "Testing" in it's field. However you question seems vague when you say 'set a value'. Another thing to add is that the editText will only take the values for when it is first instantiated.

Mark N
  • 326
  • 2
  • 13
  • yeah, i need setting a value in the input edittext but this editext is on layout that i inflate into the main layout, so why i cant settext easily like always we do?? – ferdroid8080 Jul 25 '14 at 16:58
  • what does you Log.d give...? Because it looks like you are just using an empty field to do some calculations, then assigning the empty answer to input – Mark N Jul 25 '14 at 17:03