skip to Main Content

what I am trying to do is show a custom card in a recyclerview.

I can see it on the design view on android studio, but no when the emulator runs.

I just need to display de listItem.

Is is posible? if so, any help or suggestion would be great, thanks.

    <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rcvPoolVariables"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_marginTop="22dp"
            android:layout_marginStart="17dp"
            android:layout_marginEnd="17dp"
            tools:listitem="@layout/row_pool_objectives"
            app:layout_constraintTop_toBottomOf="@+id/containerVariableAndWeeks"
            app:layout_constraintBottom_toBottomOf="parent"/>

2

Answers


  1. If the "preliminary version" is shown in the design tab, then there are no errors on the part of xml documents. It’s in "regular" code part. I think the error lies in the output of elements on the device – either you do not pass data objects for output in recycler view, or there is an error in the processing of this data. Check the recycler view classes architecture and code of an adapter class. Also read this guide, I hope it’ll help you.

    Login or Signup to reply.
  2. 1.xml

     <androidx.recyclerview.widget.RecyclerView
                    android:id="@+id/categoryview"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
                    app:spanCount="2"
                    tools:listitem="@layout/innercategorylist">
    
      </androidx.recyclerview.widget.RecyclerView>
    

    2.java file

    CategoryModel[] myListData1 = new CategoryModel[]{
                new CategoryModel( R.drawable.kiwi,"kiwi"),
                new CategoryModel(R.drawable.watermelon,"watermelon" ),
                new CategoryModel(R.drawable.strawberry,"strawberry")
    
        };
    innerCategoryAdapter = new InnerCategoryAdapter(myListData1, new InnerCategoryAdapter.HomeAdapterInterface() {
                @Override
                public void onRowClick(int searchText) {
                }
            });
    

    3.Adapter class id define and assign and model class to variable getter setter set

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search