Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.ClassCastException: You should only use a GridLayoutManager with GridRecyclerView. #14

Open
zubairsps opened this issue Feb 15, 2016 · 2 comments

Comments

@zubairsps
Copy link

Just import this sample to android studio, in activity_main I am getting following error in xml

java.lang.ClassCastException: You should only use a GridLayoutManager with GridRecyclerView.
    at com.antonioleiva.materializeyourapp.widgets.GridRecyclerView.setLayoutManager(GridRecyclerView.java:56)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.android.layoutlib.bridge.util.ReflectionUtils.invoke(ReflectionUtils.java:45)
    at com.android.layoutlib.bridge.android.support.RecyclerViewUtil.setProperty(RecyclerViewUtil.java:126)
    at com.android.layoutlib.bridge.android.support.RecyclerViewUtil.setProperty(RecyclerViewUtil.java:120)
    at com.android.layoutlib.bridge.android.support.RecyclerViewUtil.setLayoutManager(RecyclerViewUtil.java:78)
    at com.android.layoutlib.bridge.android.support.RecyclerViewUtil.setAdapter(RecyclerViewUtil.java:59)
    at android.view.BridgeInflater.setupViewInContext(BridgeInflater.java:292)
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:188)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:835)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:811)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:838)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:811)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:223)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:426)
    at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
    at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:510)
    at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:498)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:888)
    at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:498)
    at com.android.tools.idea.rendering.RenderTask.access$600(RenderTask.java:72)
    at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:610)
    at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:607)
    at com.android.tools.idea.rendering.RenderService.runRenderAction(RenderService.java:362)
    at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:607)
    at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:629)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:652)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1700(AndroidLayoutPreviewToolWindowManager.java:80)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7$1.run(AndroidLayoutPreviewToolWindowManager.java:594)
    at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:152)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:452)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:402)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:137)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7.run(AndroidLayoutPreviewToolWindowManager.java:589)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
    at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
    at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
    at com.intellij.util.Alarm$Request$1.run(Alarm.java:351)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

@zubairsps
Copy link
Author

I have replaced in activity_main.xml

<com.antonioleiva.materializeyourapp.widgets.GridRecyclerView
            android:id="@+id/recycler"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layoutAnimation="@anim/grid_layout_animation"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

With

<android.support.v7.widget.RecyclerView
            android:id="@+id/recycler"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

Now your sample is working fine but I cannot understand why its giving exception for GridRecyclerView?

@abiemann
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants