Recyclerview not call onCreateViewHolder

前端 未结 30 1364
离开以前
离开以前 2020-11-28 07:04

My RecyclerView does not call onCreateViewHolder, onBindViewHolder even MenuViewHolder constructor, therefore nothing app

相关标签:
30条回答
  • 2020-11-28 07:51

    In my case I miss to set the orientation in my LinearLayout.

    After adding orientation issue fixed.

     android:orientation="vertical"
    
    0 讨论(0)
  • 2020-11-28 07:52

    My mistake was inflating the wrong view in Fragment onCreateView.

    0 讨论(0)
  • 2020-11-28 07:52

    My problem was layout_height and layout_width of the RecyclerView set to 0dp.

    0 讨论(0)
  • 2020-11-28 07:53

    If you put wrap_content as height of your list as well as the height of your item list, nothing will show up and none of your recyclerView functions will be called. Fix the height of the item or put match_parent for the list height. That solved my problem.

    0 讨论(0)
  • 2020-11-28 07:54

    I had an issue because i setup the layout by myself and have put

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/band_recycler_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    </androidx.recyclerview.widget.RecyclerView>
    

    and

    <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/band_recycler_view"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:textAlignment="center">
    

    resolved my issue

    0 讨论(0)
  • 2020-11-28 07:55

    Other option is if you send this list objetc using get,verify if you have correct reference,for example

    private list<objetc> listObjetc;
    //Incorrect
    public void setListObjetcs(list<objetc> listObjetc){
      listObjetc = listObjetc;
    }
    
    //Correct
    public void setListObjetcs(list<objetc> listObjetc){
      this.listObjetc = listObjetc;
    }
    
    0 讨论(0)
提交回复
热议问题