安卓 SimpleAdapter 点击事件 20
这个中的点击事件怎么写??publicclassMainActivityextendsListActivity{@OverrideprotectedvoidonCreat...
这个中的点击事件怎么写??
public class MainActivity extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
SimpleAdapter adapter = new SimpleAdapter(this, getData(),
R.layout.activity_main,
new String[] { "img", "text1", "text2" },
new int[] { R.id.img_view, R.id.textview1, R.id.textview2 });
setListAdapter(adapter);
}
private List<Map<String, Object>> getData() {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
Map<String, Object> map = new HashMap<String, Object>();
map.put("img", R.drawable.tank_gailun);
map.put("text1", "盖伦");
map.put("text2", "人在塔在!");
list.add(map);
map = new HashMap<String, Object>();
map.put("img", R.drawable.ap_anni);
map.put("text1", "安妮");
map.put("text2", "再烦我就打你哟!");
list.add(map);
map = new HashMap<String, Object>();
map.put("img", R.drawable.ad_vn);
map.put("text1", "薇恩");
map.put("text2", "让我们来猎杀那些陷入黑暗中的人吧!");
list.add(map);
return list;
};
} 展开
public class MainActivity extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
SimpleAdapter adapter = new SimpleAdapter(this, getData(),
R.layout.activity_main,
new String[] { "img", "text1", "text2" },
new int[] { R.id.img_view, R.id.textview1, R.id.textview2 });
setListAdapter(adapter);
}
private List<Map<String, Object>> getData() {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
Map<String, Object> map = new HashMap<String, Object>();
map.put("img", R.drawable.tank_gailun);
map.put("text1", "盖伦");
map.put("text2", "人在塔在!");
list.add(map);
map = new HashMap<String, Object>();
map.put("img", R.drawable.ap_anni);
map.put("text1", "安妮");
map.put("text2", "再烦我就打你哟!");
list.add(map);
map = new HashMap<String, Object>();
map.put("img", R.drawable.ad_vn);
map.put("text1", "薇恩");
map.put("text2", "让我们来猎杀那些陷入黑暗中的人吧!");
list.add(map);
return list;
};
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询