Good afternoon tell me

The algorithm of the application is as follows.

First launch of the application

when you click on the onClickPhoto button, AutoCompleteTextView appears next to the variable name = mAutoComplete.getText (). toString (); a value is assigned when you click a second time on the onClickPhoto button, the condition is checked and the rest of the code works.

But all this only works when you first start the application. If you continue to work in it without restarting, then when you click on the onClickPhoto button, the action will immediately proceed to test the conditions. How to make everything repeat again?

public void onClickPhoto(View view) { name=null;//пытаюсь обнулять mAutoComplete.setVisibility(AutoCompleteTextView.VISIBLE); name = mAutoComplete.getText().toString(); //button3.setVisibility(Button.VISIBLE); if (!TextUtils.isEmpty(name)) {рабочий код} 
  • Absolutely nothing is clear - Vladyslav Matviienko
  • Uh-uh ... I guess you don’t need to clear the link to the text, but the text in mAutoComplete ... \ - Yuriy SPb
  • @Yuriy SPb paraphrased the question a little, but I already did mAutoComplete = null and my application started to fall - Varg Sieg
  • 2
    So you do not clear the text inside mAutoComplete, but mAutoComplete itself. You need to try something like mAutoComplete.setText(null); - Yuriy SPb
  • one
    @ YuriySPb there is always someone who will understand you)) - Varg Sieg

1 answer 1

You do not clear the text inside mAutoComplete , but mAutoComplete itself, i.e. a variable containing a reference to it. You need to try something like

mAutoComplete.setText(null);

To clear text, inside mAutoComplete