IllegalStateException: ViewStub must have a non-null ViewGroup viewParent

See original GitHub issue

Hi,

I think you’re setting something null and because of that, Android throws an exception.

The complete trace is:

java.lang.IllegalStateException: ViewStub must have a non-null ViewGroup viewParent
            at android.view.ViewStub.inflate(ViewStub.java:292)
            at com.marshalchen.ultimaterecyclerview.UltimateRecyclerView.setEmptyView(UltimateRecyclerView.java:183)
            at com.collect_up.c_up.fragments.ShopPagerFragment$2.onFailure(ShopPagerFragment.java:145)
            at com.collect_up.c_up.helpers.Pagination$5.onFailure(Pagination.java:123)
            at com.loopj.android.http.AsyncHttpResponseHandler.handleMessage(AsyncHttpResponseHandler.java:379)
            at com.loopj.android.http.AsyncHttpResponseHandler$ResponderHandler.handleMessage(AsyncHttpResponseHandler.java:195)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5254)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

The error was thrown because of following line that I’ve set.

mRecyclerView.setEmptyView(R.layout.empty_list_view_cause_get_data_error);

And the used layout content is:

<TextView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:text="@string/coudnt_load_data" />

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
menesscommented, Dec 7, 2015

@firasalkafri Not yet 😦 @cymcsg Sir we’re waiting for a big update. I’m using this library inside my very huge project and I really want to see regular updates. Thanks.

0reactions
lulee007commented, Dec 11, 2015

@alirezaaa try use UltimateRecyclerView.getEmptyView() and remove its children view, then inflate and add your custom view into its parent view

View view=ultimateRecyclerView.getEmptyView();
if(view!=null){
     ViewGroup viewGroup= ((ViewGroup) view.getParent());
     viewGroup.removeView(view);
viewGroup.addView(LayoutInflater.from(viewGroup.getContext()).inflate(errorViewRsid,null));
}else{
ultimateRecyclerView.setEmptyView();
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

ViewStub must have a non-null ViewGroup viewParent
It inflates correctly the first time but fails the second time citing java.lang.IllegalStateException: ViewStub must have a non-null ViewGroup ...
Read more >
ViewStub must have a non-null ViewGroup viewParent
Android – ViewStub must have a non-null ViewGroup viewParent. androidviewstub. I am using ViewStubs to load show data in my layout.
Read more >
android 解决java.lang.IllegalStateException:ViewStub ... - 简书
IllegalStateException :ViewStub must have a non-null ViewGroup viewParent android.view.ViewStub.inflate(ViewStub.java:318).
Read more >
core/java/android/view/ViewStub.java - Google Git
throw new IllegalStateException("ViewStub must have a non-null ViewGroup viewParent");. } } /**. * Specifies the inflate listener to be notified after this ...
Read more >
java.lang.IllegalStateException: ViewStub must have a non ...
java.lang.IllegalStateException: ViewStub must have a non-null ViewGroup viewParent. 暝七夜 于 2020-07-16 15:59:30 发布 1760 收藏. 分类专栏: android bug.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found