How can I override the onScroll method of the View in android? I using it for the view to prevent the update in the view's checkboxes while when I scroll. I use a two dimensional array for storing the values of the checkbox's.
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's check box
checkBox1.setchecked(true);
}
You cannot. If you with to override a method supplied in an API class you will have to extend that class. I would suggest implementing your own custom View
and override 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 find this the best way to handle the situation. I would suggest using a ViewHolder
. Basically, it is a container that holds information about your View
's items. I would recommend using it, especially if you have a list or multiple items to handle. You can read all about here in this question!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With