本文介绍了java.lang.IllegalStateException:RecyclerView没有的LayoutManager的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我得到下面的异常 -
I am getting below exception-
Caused by: java.lang.IllegalStateException: RecyclerView has no LayoutManager
at android.support.v7.widget.RecyclerView.generateLayoutParams(RecyclerView.java:2820)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:757)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at com.peoplecloud.app.guggu.NavigationDrawerFragment.onCreateView(NavigationDrawerFragment.java:75)
at android.app.Fragment.performCreateView(Fragment.java:1700)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:866)
at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1040)
at android.app.FragmentManagerImpl.addFragment(FragmentManager.java:1142)
at android.app.Activity.onCreateView(Activity.java:4803)
我添加了以下code,但我仍然得到这个例外 -
I have added the following code,however i am still getting this exception-
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
mDrawerList.setLayoutManager(layoutManager);
如果我删除回收站视图里面的内容则没有例外。
If I remove the content inside recycler view then there is no exception.
推荐答案
卸下 RecyclerView
在布局文件中的子元素。我不知道这些都应该是,但他们不应该成为孩子的 RecyclerView
。
Remove the child elements from RecyclerView
in your layout file. I don't know what those are supposed to be, but they are not supposed to be children of the RecyclerView
.
这篇关于java.lang.IllegalStateException:RecyclerView没有的LayoutManager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!