KOTLIN:
val from = arrayOf("num", "code") //定义key的名字
val to = intArrayOf(R.id.tvNumber, R.id.tvCode) //key所对应的控件id
val list: ArrayList<HashMap<String, String>> = ArrayList()
var map: HashMap<String, String> = HashMap()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_xxxx)
//put map对象
for (i in 0..250) {
log(i.toString())
map = HashMap()
map.put("num", int2Str(i))
map.put("code", arrCode[i] as String)
list.add(map)
}
//为ListView设置适配器
listViewCode.adapter = SimpleAdapter(this, list, R.layout.list_item, from, to)
}
PS:自用的 不做解释 作者:一个吃货帅锅