The first click is the opening. The second click is closing. The third click is a discovery. Etc.

while (countSchet % 2 == 0) { ArrayAdapter<String> adapter = newArrayAdapter<String>(this android.R.layout.simple_list_item_1, nameList);//Создали адаптер для занесения в listView   listView.setAdapter(adapter);  listView.setVisibility(View.VISIBLE);   countSchet=+1;     listView.setOnItemClickListener(newAdapterView.OnItemClickListener() {   @Override     //Обрабатываем нажатие на элемент public void onItemClick(AdapterView<>parent, View itemClicked, int position, long id) {     TextView textView = (TextView)itemClicked;   String strText = textView.getText().toString();         mEditText.setText(strText);//меняем mEditText     Toast toast = Toast.makeText(getApplicationContext(), "Файл сохранен", Toast.LENGTH_SHORT);     toast.show();     listView.setVisibility(View.GONE);     return;   }   }); } while (countSchet % 2 != 0) {   listView.setVisibility(View.GONE);   countSchet=+1; return; } 
  • And what, in fact, is the question? - post_zeew

2 answers 2

My magic ball says you have a typo here:

countSchet = +1;

Instead of increasing by one, you assign +1 , i.e. you need to use the += operator or in general ++ :

 countSchet += 1; //или //countSchet++; 

    And it is better to use flags if true (i.e. the window is active: listView.setVisibility (View.GONE); Otherwise listView.setVisibility (View.Visible);

    The bottom line, I think you understand