android - Custom RecyclerView Rendering Issue -


i trying make custom bouncy recyclerview hacked code...

package ...;  import android.content.context; import android.support.v7.widget.recyclerview; import android.util.attributeset; import android.util.displaymetrics;  public class bouncerecyclerview extends recyclerview {     private static final int max_y_overscroll_distance = 200;      private context mcontext;     private int mmaxyoverscrolldistance;      bouncerecyclerview(context context){         super(context);         mcontext = context;         initbouncerecyclerview();     }      bouncerecyclerview(context context, attributeset attrs){         super(context, attrs);         mcontext = context;         initbouncerecyclerview();     }      bouncerecyclerview(context context, attributeset attrs, int defstyle){         super(context, attrs, defstyle);         mcontext = context;         initbouncerecyclerview();     }      private void initbouncerecyclerview()     {         //get density of screen , maths on max overscroll distance         //variable similar behaviors no matter screen size          final displaymetrics metrics = mcontext.getresources().getdisplaymetrics();         final float density = metrics.density;          mmaxyoverscrolldistance = (int) (density * max_y_overscroll_distance * 0.25);     }      @override     protected boolean overscrollby(int deltax, int deltay, int scrollx, int scrolly,                                    int scrollrangex, int scrollrangey, int maxoverscrollx,                                    int maxoverscrolly, boolean istouchevent)     {         //this magic happens, have replaced incoming maxoverscrolly         // our own custom variable mmaxyoverscrolldistance;         return super.overscrollby(deltax, deltay, scrollx, scrolly, scrollrangex, scrollrangey,                 maxoverscrollx, mmaxyoverscrolldistance, istouchevent);     } } 

and when try use class in layout file got error:

the following classes not instantiated: - ....bouncerecyclerview (open class, show exception, clear cache)  tip: use view.isineditmode() in custom views skip code or show sample data when shown in ide 

and main part of stack:

exception details java.lang.nosuchmethodexception: ....bouncerecyclerview.<init>(android.content.context, android.util.attributeset) 

it seems me constructor (android.content.context, android.util.attributeset) parameters can't found, can see exists...

also when open bouncerecyclerview.java in android studio constructors gray , curvy underlined indicates aren't being used.


Comments