Goodnight. Upgrading the next part of my project. On my activity_xxx collected here a display of objects, where item n++ are some random headers wrapped in a cardview and so far a standard image in imageView .

<Some data came over the network ...>

The original move is still the same, and I need to pull out the headers and insert item's in place:

 for (int i = 0; i < stringObjectsDetails.length; i++) { stringObjectsDetails[i] = objectsDetails.get(i).getTitle(); } ListView listView = (ListView) findViewById(R.id.list_objects); ArrayAdapter<String> adapter = new ArrayAdapter<>(this, R.layout.object_item, stringObjectsDetails); listView.setAdapter(adapter); 

After receiving the information, my program collected it in a ListView . The question is in the correct translation of my Array type adapter into a more suitable component for a component that is not a sheet. I attach the source code:

 activity_xxx.xml (1) <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <android.support.v7.widget.RecyclerView android:id="@+id/list_objects_recycler" android:layout_width="match_parent" android:layout_height="match_parent" app:layoutManager="android.support.v7.widget.LinearLayoutManager" tools:listitem="@layout/object_item"/> </FrameLayout> object_item.xml (2) <?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="8dp"> <LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" app:srcCompat="@mipmap/ic_launcher" android:id="@+id/object_logo" /> <TextView android:id="@+id/object_title" android:layout_width="wrap_content" android:layout_height="match_parent" android:padding="8dp" tools:text="@string/title_object_string" android:layout_weight="1" /> </LinearLayout> </android.support.v7.widget.CardView> 

Ps Huge please do not advise me to use Google. I actually read even a foreign stack-flower and tried something, but I have a special situation here that seems to me, and I am still looking for a universal or some kind of flexible solution.

UPD:

enter image description here

  • one
    You want to use RecyclerView instead of ListView, but you don’t know how? - pavlofff
  • @pavlofff, yes. All that is required is to insert data into it with headers from the array. - Egor
  • one
    RecyclerView uses its RecyclerView.Adapter and an ArrayAdapter will not work for it. Rewrite your adapter under RecyclerView - EgorD
  • @EgorD, thanks! I will answer your own question if I succeed. - Egor

0