Roughly speaking on the screen we have 2 views. When clicking on each of them, a certain resource-intensive code is executed, a part of which is processed in threads (execution time is about 1 second). The trouble is that when you click, the view should immediately disappear from the screen, but the deactivation occurs only after the onClick method completes. It turns out like a hang, it suits me, it does not suit only that the view does not disappear right away. Logs showed that the property is being set, but for some reason the screen is not updated. Put invalidate (), but it did not bring success. What am I doing wrong? Logs:
view is visible true view is visible false //задержка примерно секунда, вью видна onClick is finished //вью исчезает с экрана
Code:
private class OnClicker implements OnClickListener { @Override public void onClick(View view) { Logger.d("view is visible", view.getVisibility() == View.VISIBLE); view.setVisibility(View.INVISIBLE); view.invalidate(); Logger.d("view is visible", _listMenu.getVisibility() == View.VISIBLE); switch (view.getId()) { case R.id.view1: run1(); break; case R.id.view2: run2(); break; } Logger.d("onClick is finished"); } }
run1
run2
methods run for about 1 second? - KoVadim