作者:KING逊咖 | 来源:互联网 | 2023-09-16 20:53
布局中:
代码中:
package com.zhangli.xiala;
import java.util.ArrayList;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class MainActivity extends Activity {
private ArrayList date;
private ArrayAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
date = new ArrayList();
for (int i = 0; i <20; i++) {
date.add("" + i);
}
ListView listView = (ListView) findViewById(R.id.listView);
adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, date);
listView.setAdapter(adapter);
listView.setOnScrollListener(new OnScrollListener() {
private int firstVisibleItem, visibleItemCount, totalItemCount;
// firstVisibleItem:第一条数据
// visibleItemCount:屏幕显示的数据数量
// totalItemCount:总的数据数量
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
// SCROLL_STATE_IDLE表示刷新完成
if (scrollState == OnScrollListener.SCROLL_STATE_IDLE) {
Log.d("000000000", "firstVisibleItem=" + firstVisibleItem + ",visibleItemCount=" + visibleItemCount
+ ",totalItemCount=" + totalItemCount);
boolean b = (firstVisibleItem + visibleItemCount)
上拉下拉刷新(2):http://blog.csdn.net/zhangli_/article/details/50332475