Overriding the onScroll method for com.android.View in android encoding?

How can I override the onScroll method for presentation in android? I use it for viewing to prevent updates in checkbox view while I scroll. I use a two-dimensional array to store flag values.

I use the following, but did not work for me.

public void onScroll(View view, int firstItem, int visibleItemCount, int totalItemCount { // here i check the view check box checkBox1.setchecked(true); } 
+6
source share
1 answer

You can not. If you override the method provided in the API class, you will have to extend that class. I would suggest implementing your own View and overriding the onScroll method.

 public class YourCustomView extends View { @Override public void onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { /** Whatever you need to do, do it here! */ } } 

However, I do not think this is the best way to deal with the situation. I would suggest using ViewHolder . Basically, this is a container that contains information about your View items. I would recommend using it, especially if you have a list or several items to process. You can read everything here in this question !

+1
source

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


All Articles