getText () returns null when trying to read the value of typed in an EditText

0

I have an EditText field and I want to save the Text in it by pressing a button I tried to do it using the following code but the string remains as null

    public void Botao (View view) {
      setContentView(R.layout.content_main_menu);


      EditText valor = (EditText) findViewById(R.id.ValorEdit);
      String ValorF = valor.getText().toString()

Apparently the program is only receiving the previous state of EditText and not the typed text.

    
asked by anonymous 12.01.2018 / 23:15

1 answer

3

It's because you're setting a new layout . Remove% with%

    
12.01.2018 / 23:19