onCreateViewHolder method to load the layout of the child

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout android:layout_width="match_parent"
android:layout_height="134dp"
android:layout_alignParentTop="true"
android:layout_marginTop="92dp"
android:layout_toEndOf="@+id/itemText"
android:layout_toRightOf="@+id/itemText"
xmlns:android="http://schemas.android.com/apk/res/android">

<ImageView
android:id="@+id/itemImage"
android:layout_width="109dp"
android:layout_height="134dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true" />

<TextView
android:id="@+id/itemText"
android:layout_width="wrap_content"
Android: layout_height = "match_parent"
Android: layout_alignParentLeft = "to true"
Android: layout_alignParentStart = "to true"
Android: layout_alignParentTop = "to true"
Android: layout_marginLeft = "108dp"
Android: layout_marginStart = "108dp"
Android: the layout_weight = ". 1"
Android : Gravity = "Center" />
</ the RelativeLayout>
last: data type, each data representative of a picture (R.drawable.pictureName data ID: int type) and display the text data (String type)

// custom data class
public class People {
Private String the Data; // TextView text data stored in
private int ImageId; // ImageView in picture data (in R.drawable in with an int.) Stored
People (String Data , ImageId, int) {
this.data = the Data;
this.ImageId ImageId, =;
}
public String the getData () {
return the Data;
}

public void the setData (String Data) {
the Data = Data;
}

public int getImageId (HTTP: // WWW .amjmh.com) {
return imageId,;
}

public void setImageId (int imageId) {
imageId, = imageId;
}

public String toString () {
return the Data + String.valueOf (imageId,);
}
}

Guess you like

Origin www.cnblogs.com/ly570/p/11373135.html