Для этого вы должны создать адаптер и один вид загрузки для списка,
, например, создать файл макета ресурсов, как это,
//layout/single_rsr_list_item.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@drawable/list_item_back">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="4">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:id="@+id/img_sin_list_image"
android:background="@color/black"
android:layout_marginTop="35dp"
android:layout_gravity="center_horizontal" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.2">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="SomeText SomeText SomeText SomeTextandroid:elliklm;ml;;m;psize="
android:id="@+id/tv_single_list_rsr_description"
android:textColor="@color/black"
android:textSize="15sp"
android:layout_marginTop="20dp"
android:layout_marginRight="45dp"
android:maxEms="11"
android:lines="2"
android:ellipsize="end"
android:layout_marginLeft="20dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="2015/03/13 1:10"
android:id="@+id/tv_sin_list_rsr_date"
android:layout_below="@+id/tv_single_list_rsr_description"
android:layout_marginTop="5dp"
android:textSize="12sp"
android:layout_marginLeft="20dp"
android:textColor="@color/ring_color" />
<TextView
android:layout_width="wrap_content"
android:visibility="gone"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Small Text"
android:id="@+id/tv_sin_list_rsr_id"
android:layout_below="@+id/tv_sin_list_rsr_date"
android:layout_alignLeft="@+id/tv_sin_list_rsr_date"
android:layout_alignStart="@+id/tv_sin_list_rsr_date" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Теперь создать, чтобы получить Claas то, что вам нужно, как это,
public class RSRData {
private int id;
private String description;
private String date;
private String imagePath;
public RSRData() {
}
public RSRData(int id, String imagePath, String description, String date) {
this.id = id;
this.imagePath = imagePath;
this.description = description;
this.date = date;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getImagePath() {
return imagePath;
}
public void setImagePath(String imagePath) {
this.imagePath = imagePath;
}
}
затем Wite адаптер, как это с converst это повторяющийся список, как это,
public class RSRAdapter extends ArrayAdapter<RSRData> {
Context con;
int res;
public RSRAdapter(Context context,int resource,ArrayList<RSRData> rsrData){
super(context,resource,rsrData);
this.con = context;
this.res = resource;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
RSRData rsrData=getItem(position);
if(convertView==null){
LayoutInflater inflator=LayoutInflater.from(con);
convertView=inflator.inflate(res,parent,false);
}
TextView tvTitle = (TextView)convertView.findViewById(R.id.tv_single_list_rsr_description);
tvTitle.setText(rsrData.getDescription());
TextView tvId = (TextView)convertView.findViewById(R.id.tv_sin_list_rsr_id);
tvId.setText(rsrData.getId());
TextView date = (TextView)convertView.findViewById(R.id.tv_sin_list_rsr_date);
date.setText(rsrData.getDate());
/* ImageVi = (TextView)convertView.findViewById(R.id.tv_primaryKey);
tvPrimaryKey.setText(String.valueOf(promotionData.getId()));*/
return convertView;
}
}
все-таки сделано, использовать это, чтобы установить данные на экран списка
ListView list = (ListView)findViewById(R.id.your_list);
ArrayList<RSRAdapter> data = new ArrayList<>(); // use this to get data from database and pass to here,
RSRAdapter adapter = new RSRAdapter(this,R.layout.sigle_promotion_item,data);
list.setAdapter(adapter);
@ ", но свойства от объект "и как вы отслеживаете объекты? Пожалуйста, разместите свой код. Было бы легче узнать, где вы застряли – Sufian
Почему вы хотите использовать ListView для этой цели? ListView используется для отображения списка идентичных элементов. Вы хотите показать список Личности? –
У меня есть список лиц, который отображается в первом ListView, и когда пользователь выбирает человека, следующий ListView, какие детали отображаются. Я хочу использовать ListView, потому что у человека много полей, и я бы хотел отобразить их в виде списка – DanielH