80989

Need to hide a textView while scrolling a grid view

Question:

I'm trying to hide a textView while scrolling a grid view and make the same textview visible again when the user stops scrolling. Can anyone help me fixing this issue..?

Answer1:

implement OnScrollListener and then inside the onScroll make the textView invisible and in the OnScrollStateChanged method check if the scroll stopped and make it visibile again

private OnScrollListener mScrollListener = new OnScrollListener() { @Override public void onScrollStateChanged(ViewGroup view, int scrollState) { if(scrollState == SCROLL_STATE_IDLE) { textView.setVisibility = View.VISIBLE; } @Override public void onScroll(ViewGroup view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { textView.setVisibility = View.INVISIBLE } };

Answer2:

You can use setVisibility in OnScrollListener

Example:

gridview.setOnScrollListener(new OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { if(scrollState == SCROLL_STATE_IDLE) { textview.setVisibility(View.VISIBLE); } } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { textview.setVisibility(View.GONE); } });

Hope it helps.

Answer3:

gridView.setOnScrollListener(new OnScrollListener() {

@Override public void onScrollStateChanged(AbsListView view, int scrollState) { if(scrollState == SCROLL_STATE_IDLE) { textview.setVisibility(View.VISIBLE); } } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { textview.setVisibility(View.GONE); }

});

We use this code in my app and it work , I hope it will useful to you.

Answer4:

Try this code:

private OnScrollListener mScrollListener = new OnScrollListener() { @Override public void onScrollStateChanged(ViewGroup view, int scrollState) { if(scrollState == SCROLL_STATE_IDLE) { tv.setVisibility(View.VISIBLE); } } @Override public void onScroll(ViewGroup view, int firstVisibleItem, int visibleItemCount, int totalount) { tv.setVisibility(View.INVISIBLE); } });

Answer5:

Try this:

Private OnScrollListener mScrollListener = new OnScrollListener() { @Override public void onScrollStateChanged(ViewGroup view, int scrollState) { if(scrollState == SCROLL_STATE_IDLE) { mTextView.setVisibility = View.VISIBLE; } @Override public void onScroll(ViewGroup view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { mTextView.setVisibility = View.INVISIBLE } };

Answer6:

You need to set this method on your gridview. it works for me. I am sure it will help you.

gridAdmin.setOnScrollListener(new OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { if(scrollState == SCROLL_STATE_IDLE) { text1.setVisibility = View.VISIBLE; } } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { text1.setVisibility = View.INVISIBLE } });

Recommend

  • Set first visible item in Android gridview completely seen
  • How can I hide tabs while scrolling down a ListView then show them again if the user scrolls up?
  • ListView scroll - one by one
  • Overflow: auto on html,body breaks jQuery .animate scroll to top?
  • Behaviour of System.Timer when Interval property changed
  • Prolog binary search tree test - unwanted parents' parent node comparison
  • IntelliJ - debug mode - search text in program memory
  • JQM (jQueryMobile) Problem with AJAX content and focus()
  • wrong item changes in recyclerview
  • How to expand parent div to account for child's overflow?
  • Implementing Oracle.Web.dll, Oracle.DataAccess.dll 64-bit failed on Windows Server 2008 with IIS 7.5
  • Does “internal” visibility modifier in Kotlin work yet?
  • Laravel at least one field is required
  • Loading Bitmap to ImageView from URL in android
  • What is the difference between a “service account” and an “installed application”?
  • IE10 strips out hashtag from the URL
  • Need code translation from VB to C#
  • Change Checkbox value without raising event
  • C# List of Panels
  • Synchronize windows folders
  • Is there a way to dynamically embed PDF Files in a JSP pulled from the file system?
  • Retrieving specified columns from a list of csv files to create a data data frame in R
  • Primefaces ManyCheckbox inside ui:repeat calls setter method only for last loop
  • using System.Speech.Synthesis with Windows10 universal app (XAML-C#)
  • Check all values in string[] for length?
  • Image map in Flex
  • Build Successful but not running on simulator
  • Django model inheritance, filtering models
  • Jquery popup on mouse over of calendar control
  • Check for zero lines output from command over SSH
  • How to clear text inside text field when radio button is select
  • How to avoid particles glitching together in an elastic particle collision simulator?
  • Recording logins for password protected directories
  • Splitting given String into two variables - php
  • Align navbar back button on right side
  • Check if a string to interpolate provides expected placeholders
  • Trying to switch camera back to front but getting exception
  • Free memory of cv::Mat loaded using FileStorage API
  • Angular 2 constructor injection vs direct access
  • Programmatically clearing map cache