GithubHelp home page GithubHelp logo

Null Pointer exception about superslim HOT 6 CLOSED

tonicartos avatar tonicartos commented on July 18, 2024
Null Pointer exception

from superslim.

Comments (6)

TonicArtos avatar TonicArtos commented on July 18, 2024

It looks like your adapter is providing views without layout parameters. Whilst I prefer this to not be the case, I agree that it is a bug for the library to crash on it.

from superslim.

kcorwin avatar kcorwin commented on July 18, 2024

Just a quick observation - I was also getting this exception, even when my views had layout params set. Turned out the problem is that my layoutParams.sectionFirstPosition in my views were incorrect - I was setting it to the index of the first (non-header) item in the section, when it's supposed to be the position of the section header itself.

from superslim.

ab-helly avatar ab-helly commented on July 18, 2024

I'm also getting this error in case if there is single item in the list

from superslim.

TonicArtos avatar TonicArtos commented on July 18, 2024

This is a problem with the scroll indicator computation, which has been removed for now as it is bad, inaccurate, and will be wholly replaced after the section layout manager design changes.

from superslim.

jesielin avatar jesielin commented on July 18, 2024

i encounter the similar problem:
java.lang.NullPointerException: Attempt to read from field 'int android.view.ViewGroup$LayoutParams.width' on a null object reference
at android.view.ViewGroup$LayoutParams.(ViewGroup.java:6403)
at android.view.ViewGroup$MarginLayoutParams.(ViewGroup.java:6685)
at android.support.v7.widget.RecyclerView$LayoutParams.(RecyclerView.java:7420)
at com.tonicartos.superslim.LayoutManager$LayoutParams.(LayoutManager.java:1819)
at com.tonicartos.superslim.GridSLM$LayoutParams.(GridSLM.java:506)
at com.tonicartos.superslim.GridSLM$LayoutParams.from(GridSLM.java:520)
at com.zihexin.cwapp.activity.CityActivity$CountryAdapter.onBindViewHolder(CityActivity.java:111)
at com.zihexin.cwapp.activity.CityActivity$CountryAdapter.onBindViewHolder(CityActivity.java:70)
at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:4402)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:3717)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:3609)
at com.tonicartos.superslim.LayoutState.getView(LayoutState.java:44)
at com.tonicartos.superslim.LayoutManager.layoutChildren(LayoutManager.java:1316)
at com.tonicartos.superslim.LayoutManager.onLayoutChildren(LayoutManager.java:264)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:2118)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:2415)
at android.view.View.layout(View.java:15596)
at android.view.ViewGroup.layout(ViewGroup.java:4966)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
at android.view.View.layout(View.java:15596)
at android.view.ViewGroup.layout(ViewGroup.java:4966)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
at android.view.View.layout(View.java:15596)
at android.view.ViewGroup.layout(ViewGroup.java:4966)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
at android.view.View.layout(View.java:15596)
at android.view.ViewGroup.layout(ViewGroup.java:4966)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
at android.view.View.layout(View.java:15596)
at android.view.ViewGroup.layout(ViewGroup.java:4966)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
at android.view.View.layout(View.java:15596)
at android.view.ViewGroup.layout(ViewGroup.java:4966)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
at android.view.View.layout(View.java:15596)
at android.view.ViewGroup.layout(ViewGroup.java:4966)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2072)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1829)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1054)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5779)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
at android.view.Choreographer.doCallbacks(Choreographer.java:580)
at android.view.Choreographer.doFrame(Choreographer.java:550)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.M
and i think i solve it
in onCreateViewHolder method, i use View.inflate(mContext,R.layout.item_country_content,null); before to get the itemView,and then i got the problem,finally,i change to this:
view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.item_country_content, viewGroup, false); and problem solved
just write here to help others

from superslim.

TonicArtos avatar TonicArtos commented on July 18, 2024

@jesielin What you encountered is a bug. The configuration you had should had caused the layout manager to assign sensible default layout parameters to the item. This bug will be tracked in #74.

from superslim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.