Show / hide view list

I use listview in my activity. Now I need to hide the list for a certain period of time and then it should be displayed. It is similar to our video players, in which search bars are automatically hidden and when the user touches it, the same find that I need to achieve in my activity will be displayed. Instead of searching i, you need to hide your list from the screen. Just show / hide lists for alternative purposes. There is a new one. So guide me in achieving this. Thanks in advance.

+4
source share
2 answers

You have a view similar to the playback view of a video player.

View alwaysAppearingView; 

And you have a listView that you want to hide automatically after a delay.

 ListView listView; 

Let implements OnTouchListener for alwaysAppearingView;

  alwaysAppearingView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { listView.setVisibility(View.VISIBLE); listView.postDelayed(new Runnable() { @Override public void run() { listView.setVisibility(View.GONE); // or View.INVISIBLE as Jason Leung wrote } }, 3000); return true; } }); 

You check every touch, when you touch, you make the ListView visible and if you don’t have touches for 3000 milliseconds (3 seconds), the listView disappears. Give it a try.

+5
source

Not sure what you want for sure, but to hide any views in Android just set the visibility :)

 listview.setVisibility(View.GONE); 

or View.INVISIBLE if you want the view to still occupy the screen space

 listview.setVisibility(View.INVISIBLE); 

to return it

 listview.setVisibility(View.VISIBLE); 
+8
source

Source: https://habr.com/ru/post/1500852/


All Articles