为了账号安全,请及时绑定邮箱和手机立即绑定

package com.example.listvie;


import java.util.ArrayList;

import java.util.HashMap;

import java.util.List;

import java.util.Map;


import android.app.Activity;

import android.view.ActionMode;

import android.widget.ArrayAdapter;

import android.widget.ListView;

import android.widget.SimpleAdapter;


public class simple extends Activity{

private ListView listView;

private SimpleAdapter simple;

// private String []from = {"tv","img"};

// private int [] to = {R.id.tv,R.id.img};

private List<Map<String,Object>>DataList;

@Override

public void onActionModeFinished(ActionMode mode) {

super.onActionModeFinished(mode);

setContentView(R.layout.main);

listView = (ListView) findViewById(R.id.listView1);

DataList = new ArrayList<Map<String,Object>>();

simple = new SimpleAdapter(this, getDataList(), R.layout.view, new String[]{"tv","img"}, new int []{R.id.tv,R.id.img});

listView.setAdapter(simple);

}

private List<Map<String,Object>> getDataList() {

for(int i=0;i<20;i++){

Map<String,Object>map = new HashMap<String,Object>();

map.put("tv", "0.0+i");

map.put("img",R.drawable.ic_launcher);

DataList.add(map);

}

return DataList;

}



}


正在回答

0 回答

举报

0/150
提交
取消
Android攻城狮的第二门课(第1季)
  • 参与学习       111161    人
  • 解答问题       1457    个

本课程由浅入深地带您学会Android的常用控件的开发和使用

进入课程
意见反馈 帮助中心 APP下载
官方微信