Closed encouver closed 7 years ago
you mean you got a crash when you run my sample app?
The sample run flawlessly.
It's in my app that is showing the error at runtime just in the starting of the app.
The library is included in the gradle file, and the tags are just a copy paste of your sample app.
can i see the code where the error happens??
Fragment:
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState);
final View rootView = inflater.inflate(R.layout.fragment_mapa_nc, container, false);
. . .
LinearLayoutManager managerProductos = new LinearLayoutManager(rootView.getContext(), LinearLayoutManager.HORIZONTAL, false);
recyclerViewProductos.setLayoutManager(managerProductos);
LinearLayoutManager managerServicios = new LinearLayoutManager(rootView.getContext(), LinearLayoutManager.HORIZONTAL, false);
recyclerViewProductos.setLayoutManager(managerServicios);
. . . return rootView; }
After the onCreateView return, shows the error in the StackTrace
Gradle: compile "com.github.takusemba:multisnaprecyclerview:1.0.2"
Layout with the issue:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="60dp" android:orientation="vertical" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context="com.zzzzz.xx.ListaClientesActivity" tools:showIn="@layout/activity_lista_clientes">
<!-- A RecyclerView with some commonly used attributes -->
<android.support.v7.widget.RecyclerView
android:id="@+id/vistaListaPro"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:padding="2dp"
android:layout_height="match_parent" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="Productos"
android:textSize="16sp" />
<com.takusemba.multisnaprecyclerview.MultiSnapRecyclerView
android:id="@+id/recyclerViewPr"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
app:msrv_gravity="start"
app:msrv_snap_count="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:text="Servicios"
android:textSize="16sp" />
<com.takusemba.multisnaprecyclerview.MultiSnapRecyclerView
android:id="@+id/recyclerViewSe"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
app:msrv_gravity="start"
app:msrv_snap_count="1" />
StackTrace:
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.zzzzz.xx, PID: 29758 java.lang.IllegalArgumentException: other than LinearLayoutManger is not supported at com.takusemba.multisnaprecyclerview.MultiSnapRecyclerView.onAttachedToWindow(MultiSnapRecyclerView.java:48) at android.view.View.dispatchAttachedToWindow(View.java:17184) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3289) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3296) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3296) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3296) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3296) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3296) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3296) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3296) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3296) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3296) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3296) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3296) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3296) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3296) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3296) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3296) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1657) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1385) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6722) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:886) at android.view.Choreographer.doCallbacks(Choreographer.java:698) at android.view.Choreographer.doFrame(Choreographer.java:633) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:872) at android.os.Handler.handleCallback(Handler.java:769) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6540) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 08-16 04:06:23.672 29758-29758/com.zzzzz.xxE/UncaughtException: java.lang.IllegalArgumentException: other than LinearLayoutManger is not supported at com.takusemba.multisnaprecyclerview.MultiSnapRecyclerView.onAttachedToWindow(MultiSnapRecyclerView.java:48) at android.view.View.dispatchAttachedToWindow(View.java:17184) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3289) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3296) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3296) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3296) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3296) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3296) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3296) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3296) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3296) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3296) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3296) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3296) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3296) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3296) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3296) at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:3296) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1657) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1385) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6722) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:886) at android.view.Choreographer.doCallbacks(Choreographer.java:698) at android.view.Choreographer.doFrame(Choreographer.java:633) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:872) at android.os.Handler.handleCallback(Handler.java:769) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6540) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Thank you for the code!! I'll look into it. give me a few days.
it seems like recyclerView doesn't have a layoutManager at the point where you return view in onCreateView
can you check if the recyclerView has a layoutManager at the end of onCreateView by simplely printing recyclerView.getLayoutManager?
The error was that I had two layoutManagers and the second was not initialized, it was something I didn't realize until now. It was a copy and paste and not checking.
LinearLayoutManager managerProductos = new LinearLayoutManager(rootView.getContext(), LinearLayoutManager.HORIZONTAL, false); recyclerViewProductos.setLayoutManager(managerProductos);
LinearLayoutManager managerServicios = new LinearLayoutManager(rootView.getContext(), LinearLayoutManager.HORIZONTAL, false);
recyclerViewServicios.setLayoutManager(managerServicios);
I'm closing this issue.
thanks
When running the app, it throws "java.lang.IllegalArgumentException: other than LinearLayoutManger is not supported" being that at onAttachedToWindow, mLayout is null therefore is not an instance of LinearLayoutManager.
So what's happening here?