一、添加ListView控件:
<ListViewandroid:id="@+id/listView"android:layout_width="match_parent"android:layout_height="match_parent"app:layout_constraintBottom_toBottomOf="parent"app:layout_constraintTop_toTopOf="parent"tools:layout_editor_absoluteX="1dp" />
二、类文件Country.java:
package com.july.listviewapp;public class Country {private String name;private int icon;public Country(String name,int icon){this.name = name;this.icon = icon;}public String getName(){return name;}public void setName(String name){this.name = name;}public int getIcon(){return icon;}public void setIcon(int icon){this.icon = icon;}}
三、子布局文件:
<?xml version="1.0"