UltimateRecyclerView icon indicating copy to clipboard operation
UltimateRecyclerView copied to clipboard

Viewstub must have a valid layout resource error

Open gandalf76 opened this issue 8 years ago • 14 comments

I have this error after calling notifydatasetchanged.

gandalf76 avatar Mar 18 '16 22:03 gandalf76

try not to using it.

jjhesk avatar Mar 31 '16 15:03 jjhesk

removing notifydatasetchanged, i have the following error: attempt to write to field 'int android.support.v7.widget.RecyclerView$ViewHolder.mItemViewType' on a null object reference

gandalf76 avatar Apr 02 '16 08:04 gandalf76

Can be beacuse recyclerview is trying to call setVisibility on ViewStub when ViewStub is not actually inflated? instead build 0.3.18 is working well

gandalf76 avatar Apr 05 '16 12:04 gandalf76

Yeah I have the same issue.

Bolling88 avatar Apr 07 '16 11:04 Bolling88

I encountered the same issue. Is there any update on this?

dlet24 avatar Apr 08 '16 09:04 dlet24

I encountered the same error too using compile 'com.hkm.slidingmenulib:libmenu:0.4.9' even when there are data. However, on the older version build like 0.3.18 works well.

04-11 13:13:48.932: E/AndroidRuntime(23408): Caused by: java.lang.IllegalArgumentException: ViewStub must have a valid layoutResource
04-11 13:13:48.932: E/AndroidRuntime(23408):    at android.view.ViewStub.inflate(ViewStub.java:289)
04-11 13:13:48.932: E/AndroidRuntime(23408):    at android.view.ViewStub.setVisibility(ViewStub.java:240)
04-11 13:13:48.932: E/AndroidRuntime(23408):    at com.marshalchen.ultimaterecyclerview.UltimateRecyclerView.updateHelperDisplays(UltimateRecyclerView.java:868)
04-11 13:13:48.932: E/AndroidRuntime(23408):    at com.marshalchen.ultimaterecyclerview.UltimateRecyclerView.access$600(UltimateRecyclerView.java:61)
04-11 13:13:48.932: E/AndroidRuntime(23408):    at com.marshalchen.ultimaterecyclerview.UltimateRecyclerView$3.onChanged(UltimateRecyclerView.java:823)
04-11 13:13:48.932: E/AndroidRuntime(23408):    at android.support.v7.widget.RecyclerView$AdapterDataObservable.notifyChanged(RecyclerView.java:9242)
04-11 13:13:48.932: E/AndroidRuntime(23408):    at android.support.v7.widget.RecyclerView$Adapter.notifyDataSetChanged(RecyclerView.java:5493)

lkwjohn avatar Apr 11 '16 05:04 lkwjohn

Have this bug been fixed?

0LongLongAgo avatar Apr 11 '16 05:04 0LongLongAgo

Just found another similar bug, but now it came from removeInternal

4-11 14:08:27.882: E/AndroidRuntime(5283): Caused by: java.lang.IllegalArgumentException: ViewStub must have a valid layoutResource
04-11 14:08:27.882: E/AndroidRuntime(5283):     at android.view.ViewStub.inflate(ViewStub.java:289)
04-11 14:08:27.882: E/AndroidRuntime(5283):     at android.view.ViewStub.setVisibility(ViewStub.java:240)
04-11 14:08:27.882: E/AndroidRuntime(5283):     at com.marshalchen.ultimaterecyclerview.UltimateRecyclerView.updateHelperDisplays(UltimateRecyclerView.java:868)
04-11 14:08:27.882: E/AndroidRuntime(5283):     at com.marshalchen.ultimaterecyclerview.UltimateRecyclerView.access$600(UltimateRecyclerView.java:61)
04-11 14:08:27.882: E/AndroidRuntime(5283):     at com.marshalchen.ultimaterecyclerview.UltimateRecyclerView$3.onItemRangeRemoved(UltimateRecyclerView.java:811)
04-11 14:08:27.882: E/AndroidRuntime(5283):     at android.support.v7.widget.RecyclerView$AdapterDataObservable.notifyItemRangeRemoved(RecyclerView.java:9276)
04-11 14:08:27.882: E/AndroidRuntime(5283):     at android.support.v7.widget.RecyclerView$Adapter.notifyItemRemoved(RecyclerView.java:5653)
04-11 14:08:27.882: E/AndroidRuntime(5283):     at com.marshalchen.ultimaterecyclerview.UltimateViewAdapter.removeInternal(UltimateViewAdapter.java:429)
04-11 14:08:27.882: E/AndroidRuntime(5283):     at sg.ListAdapter.removeItemAt(ListAdapter.java:124)

My adapter have extends UltimateViewAdapter.

It was working fine on 0.3.18 as well.

lkwjohn avatar Apr 11 '16 06:04 lkwjohn

Hey guys, after looking through the UltimateRecyclerView.java, which i realise that now the structure for the library require the mEmpty to be inflate first and this can be done using the following: ultimateRecyclerView.setEmptyView(R.layout.empty_view, R.id.no_image);

Thus, this helps me to resolve the above issue.

lkwjohn avatar Apr 11 '16 07:04 lkwjohn

greate!

0LongLongAgo avatar Apr 11 '16 07:04 0LongLongAgo

tnx @lkwjohn "setEmptyView" works

ergunkocak avatar Apr 25 '16 14:04 ergunkocak

You can also set that in the layout, e.g.:

<com.marshalchen.ultimaterecyclerview.UltimateRecyclerView
...
app:recyclerviewEmptyView="@layout/empty_view"/>

reference: http://blog.marshalchen.com/UltimateRecyclerView/

jackcsk avatar Jun 08 '16 02:06 jackcsk

@jackcsk Emptyview not showing even if I add this in xml or using "setEmptyView" in code, leaving a huge white area on the screen. Any idea on what happened?

passerbyABC123 avatar Aug 16 '16 12:08 passerbyABC123

@lkwjohn @cymcsg ultimateRecyclerView.setEmptyView(@LayoutRes int emptyResourceId, final int emptyViewPolicy);

after read source code, the second param needs pass a Policy Id I think, but the comment is @param emptyViewPolicy the Resource Id from the empty view is that wrong?

SwiftyWang avatar Oct 28 '16 07:10 SwiftyWang