Android-Image-Slider icon indicating copy to clipboard operation
Android-Image-Slider copied to clipboard

Error getCount() java.lang.NullPointerException

Open mrminhhuy opened this issue 7 years ago • 5 comments

Hi, have an error when run app. It's rise "java.lang.NullPointerException: Attempt to invoke virtual method 'int androidx.viewpager.widget.PagerAdapter.getCount()' on a null object reference at com.smarteist.autoimageslider.SliderView$2.run(SliderView.java:397)..."

mrminhhuy avatar Jun 19 '19 02:06 mrminhhuy

Hi, have an error when run app. It's rise "java.lang.NullPointerException: Attempt to invoke virtual method 'int androidx.viewpager.widget.PagerAdapter.getCount()' on a null object reference at com.smarteist.autoimageslider.SliderView$2.run(SliderView.java:397)..."

always call notifyDataSetChanged() method when adapter data is changed.

smarteist avatar Jun 19 '19 07:06 smarteist

Hi, thanks for your response. But, it's still not work. It's rise more errors. "java.lang.NullPointerException: Attempt to invoke virtual method 'void adapter.notifyDataSetChanged()' on a null object reference" in updateView

mrminhhuy avatar Jun 19 '19 07:06 mrminhhuy

Hi, thanks for your response. But, it's still not work. It's rise more errors. "java.lang.NullPointerException: Attempt to invoke virtual method 'void adapter.notifyDataSetChanged()' on a null object reference" in updateView

Because the slider adapter is null there. first set adapter to sliderview then update your views.

smarteist avatar Jun 19 '19 08:06 smarteist

Yep, i'm set adapter in initView, and notifyDataSetChanged in updateView. But, it's still rise errors

mrminhhuy avatar Jun 19 '19 08:06 mrminhhuy

done. It worked for me. Thanks so much

mrminhhuy avatar Jun 20 '19 03:06 mrminhhuy