android之listview点击监听和长按监听的实现和区分

listview 实现点击和长按以及区分


import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;

接口实现

		peopleListView.setOnItemClickListener(new OnItemClickListener() {
			@Override
			public void onItemClick(AdapterView parent, View view,
					int position, long id) {
				
			}
		});
		peopleListView.setOnItemLongClickListener(new OnItemLongClickListener() {
			@Override
			public boolean onItemLongClick(AdapterView parent,
					View view, int position, long id) {
				
				//区分关键
				return true;
			}
		});
长按监听的返回值可以区分来

返回true:只会执行长按监听

返回false:长按之后会接着执行点击监听

你可能感兴趣的:(android)