listView屏幕滑动监听事件

listView.setOnScrollListener(this);

@Override
	public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
		// TODO Auto-generated method stub
		String text = listView.getItemAtPosition(position)+" " ;//position为点击位置
		Toast.makeText(this,  text, 1).show();
	}

	@Override
	public void onScrollStateChanged(AbsListView view, int scrollState) {
		// TODO Auto-generated method stub
		switch(scrollState){
		case  SCROLL_STATE_FLING:             //滑动状态,急剧滑动,带有惯性
			Map map=new HashMap();
			map.put("pic", R.drawable.abc_ab_bottom_solid_dark_holo);
			map.put("text", "小机器人");
			list.add(map);
			sim_adapter.notifyDataSetChanged();
			break;
	   case  SCROLL_STATE_IDLE:                 //闲置状态
			break;
		case SCROLL_STATE_TOUCH_SCROLL:         //触摸状态
		    break;
		 default:
			
			 break;
		}
		
			
	}

猜你喜欢

转载自blog.csdn.net/weixin_43592833/article/details/86499039
今日推荐