1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
| package com.example.final_test1;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.SimpleAdapter;
public class listplace extends Activity{
private ListView listView;
private List<HashMap<String, String>> mdaList = new ArrayList<HashMap<String,String>>();
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listplace);
setData();
listView = (ListView)findViewById(R.id.listView1);
String from[] = new String[] { "info", "content" };
int to[] = new int[] { R.id.info, R.id.content };
SimpleAdapter spAdapter = new SimpleAdapter(this, mdaList, R.layout.listviewitem, from, to);
OnItemClickListener clItemClickListener = new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
Bundle bundle = new Bundle();
bundle.putString("info", (String)mdaList.get(arg2).get("info"));
bundle.putString("content", (String)mdaList.get(arg2).get("content"));
bundle.putString("address", (String)mdaList.get(arg2).get("address"));
bundle.putString("phone", (String)mdaList.get(arg2).get("phone"));
Intent intent = new Intent();
intent.setClass(listplace.this, c1.class);
intent.putExtras(bundle);
startActivity(intent);
finish();
}
};
listView.setAdapter(spAdapter);
listView.setOnItemClickListener(clItemClickListener);
}
private void setData(){
HashMap<String, String> map = new HashMap<String, String>();
map.put("info", "中山大学特惠信息");
map.put("content", "湖畔餐厅打折套餐");
map.put("address", "内环东路中大生活区");
map.put("phone", "135XXXX8888");
mdaList.add(map);
map = new HashMap<String, String>();
map.put("info", "广东外语外贸大学特惠信息");
map.put("content", "云山水榭,5折k歌");
map.put("address", "内环东路广外生活区");
map.put("phone", "136XXXX9900");
mdaList.add(map);
map = new HashMap<String, String>();
map.put("info", "华南师范大学特惠信息");
map.put("content", "华师体育用品");
map.put("address", "中环西路华师生活区");
map.put("phone", "137XXXX4458");
mdaList.add(map);
}
}
|