setOnItemClickListener();监听被点击的item
// 绑定数据生成列表
ArrayList
SimpleAdapter listItemAdapter = new SimpleAdapter(this, list,
R.layout.listitem, new String[] { "name", "status" },
new int[] { R.id.textViewFilename, R.id.textViewStatus });
ListView lv = (ListView) findViewById(R.id.listViewFilelist);
lv.setAdapter(listItemAdapter);
lv.setOnItemClickListener(itemclick);
}
OnItemClickListener itemclick = new OnItemClickListener() {
@Override
public void onItemClick(AdapterView> arg0, View arg1, int arg2,
long arg3) {
try {
String filename = fileList[arg2];
Intent intent = new Intent(ActFileList.this,
ActFileDownloader.class);
intent.putExtra("filename", filename);
intent.putExtra("serverip", serverip);
intent.putExtra("saveto", saveto);
startActivity(intent);
} catch (NullPointerException e) {
// 没有数据,不操作
}
}
};