Android ListView简单使用及滚动事件

String[] strs = {"1","2","3","4","5"};  
ArrayAdapter adapter = new ArrayAdapter(SafetyRecordFormActivity.this,android.R.layout.simple_expandable_list_item_1,strs);  
list.setAdapter(adapter); 

滚动监听解析:
1、增加接口OnScrollListener
2、重写滚动方法

@Override
public void onScrollStateChanged(AbsListView arg0, int arg1) {
	// TODO Auto-generated method stub
	switch (arg1) {
	case SCROLL_STATE_FLING:
		//手指离开屏幕后,列表惯性滑动的过程
		break;


	case SCROLL_STATE_IDLE:
		//列表停止滑动
		break;
		
	case SCROLL_STATE_TOUCH_SCROLL:
		//手指未离开屏幕,列表正在滑动的过程
		break;
	}
}

/获取position对应的item中的内容

listView.getItemAtPosition(position);

你可能感兴趣的:(控件功能)