ListView&SimpleAdapter ListView 中使用SimpleAdapter lv.setOnItemClickListener(new MyOnItemClickListener());再加上这样一个事件监听 为什么会没反应?listviewsimpleadapter 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这样谁能回答你?看看这篇文章,比较基础http://blog.csdn.net/fs1360472174/article/details/8822719 就是在给一个使用了SimpleAdapter适配器的ListView设置了一个监听器 lv.setOnItemClickListener(new MyOnItemClickListener());class MyOnItemClickListener implements OnItemClickListener{ public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { System.out.println(arg0); System.out.println(arg1); System.out.println(arg2); System.out.println(arg3); } }但是不论你怎么点 都不会有反应的 控制台不会输出任何东西 没有 具体代码如下package com.niu.app;import java.util.HashMap;import java.util.Map;import java.util.Vector;import android.app.Activity;import android.os.Bundle;import android.view.View;import android.view.Window;import android.view.WindowManager;import android.widget.AdapterView;import android.widget.AdapterView.OnItemClickListener;import android.widget.Button;import android.widget.LinearLayout;import android.widget.ListView;import android.widget.SimpleAdapter;public class SimpleAdapterActivity extends Activity { class MyOnItemClickListener implements OnItemClickListener{ public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { System.out.println(arg0); System.out.println(arg1); System.out.println(arg2); System.out.println(arg3); } } protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ListView lv = new ListView(this); this.requestWindowFeature(Window.FEATURE_NO_TITLE); this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); String[] names = { "小明", "小红", "小强", "小花", "小刚" }; String[] dels = { "删除1", "删除2", "删除3", "删除4", "删除5" }; String[] upds = { "修改1", "修改2", "修改3", "修改4", "修改5" }; Vector<Map<String, Object>> v = new Vector(); for (int i = 0; i < names.length; i++) { HashMap map = new HashMap(); map.put("stuName", names[i]); map.put("dels", dels[i]); map.put("upds", upds[i]); v.add(map); } SimpleAdapter adapter = new SimpleAdapter(this, v, R.layout.simple_list_item, new String[] { "stuName", "dels", "upds" }, new int[] { R.id.text_names, R.id.button_dels, R.id.button_upds }); lv.setAdapter(adapter); lv.setOnItemClickListener(new MyOnItemClickListener()); LinearLayout line = new LinearLayout(this); line.setOrientation(LinearLayout.VERTICAL); Button b = new Button(this); b.setText("添加"); line.addView(b); line.addView(lv); this.setContentView(line); }} 这段代码是ListItem部分Click是正常工作的 NDK中jmethodID需要释放吗 android 的有关ListView的添加字符串数组的问题~~~急求解 关于Android远程登录含有loading效果的程序的问题 listview中imagbutton单击事件 Android系统调用带有ACTIVITX 控件的ASP.NET网页有效果吗 积分很难弄到啊! 请教下android用什么来写程序挂起? 高手多线程操作的文章 安卓4.2.2 调节音量的函数如何换成自己的代码(内详细) 请教下android布局的问题 现在googlemap v1的apikey已经不能申请了,v2的怎么申请呢 请教个关于dlna镜像传输的问题
看看这篇文章,比较基础
http://blog.csdn.net/fs1360472174/article/details/8822719
lv.setOnItemClickListener(new MyOnItemClickListener());class MyOnItemClickListener implements OnItemClickListener{ public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
System.out.println(arg0);
System.out.println(arg1);
System.out.println(arg2);
System.out.println(arg3);
}
}但是不论你怎么点 都不会有反应的 控制台不会输出任何东西
import java.util.Map;
import java.util.Vector;import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.SimpleAdapter;public class SimpleAdapterActivity extends Activity {
class MyOnItemClickListener implements OnItemClickListener{ public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
System.out.println(arg0);
System.out.println(arg1);
System.out.println(arg2);
System.out.println(arg3);
}
} protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); ListView lv = new ListView(this);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN); String[] names = { "小明", "小红", "小强", "小花", "小刚" };
String[] dels = { "删除1", "删除2", "删除3", "删除4", "删除5" };
String[] upds = { "修改1", "修改2", "修改3", "修改4", "修改5" }; Vector<Map<String, Object>> v = new Vector(); for (int i = 0; i < names.length; i++) {
HashMap map = new HashMap();
map.put("stuName", names[i]);
map.put("dels", dels[i]);
map.put("upds", upds[i]);
v.add(map);
} SimpleAdapter adapter = new SimpleAdapter(this, v,
R.layout.simple_list_item, new String[] { "stuName", "dels",
"upds" }, new int[] { R.id.text_names,
R.id.button_dels, R.id.button_upds });
lv.setAdapter(adapter);
lv.setOnItemClickListener(new MyOnItemClickListener()); LinearLayout line = new LinearLayout(this);
line.setOrientation(LinearLayout.VERTICAL); Button b = new Button(this);
b.setText("添加"); line.addView(b);
line.addView(lv); this.setContentView(line); }
}