zoukankan      html  css  js  c++  java
  • Pull刷新加载

    package com.example.huangj5;

    import java.util.ArrayList;
    import java.util.List;

    import com.handmark.pulltorefresh.library.PullToRefreshBase;
    import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener2;
    import com.handmark.pulltorefresh.library.PullToRefreshGridView;
    import com.lidroid.xutils.BitmapUtils;

    import android.app.Activity;
    import android.os.Bundle;
    import android.view.Menu;
    import android.view.MenuItem;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.BaseAdapter;
    import android.widget.GridView;
    import android.widget.ImageView;
    import android.widget.TextView;

    public class MainActivity extends Activity {

        private PullToRefreshGridView pull_refresh_grid;
        int qwe = 10;
        private List<String> asd;
        private MyAdapter m;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            Data();
            pull_refresh_grid = (PullToRefreshGridView)findViewById(R.id.pull_refresh_grid);
            m = new MyAdapter();
            pull_refresh_grid.setAdapter(m);
            pull_refresh_grid.setOnRefreshListener(new OnRefreshListener2<GridView>() {


                @Override
                public void onPullDownToRefresh(
                        PullToRefreshBase<GridView> refreshView) {
                qwe = qwe+5;
                Data();
                m = new MyAdapter();
                pull_refresh_grid.setAdapter(m);
                m.notifyDataSetChanged();
                pull_refresh_grid.onRefreshComplete();
                
                }
                @Override
                public void onPullUpToRefresh(
                        PullToRefreshBase<GridView> refreshView) {
                    qwe = qwe+1;
                    Data();
                    m = new MyAdapter();
                    pull_refresh_grid.setAdapter(m);
                    m.notifyDataSetChanged();
                    pull_refresh_grid.onRefreshComplete();    
                }

            });
            
        }
        class MyAdapter extends BaseAdapter{

            @Override
            public int getCount() {
                return asd.size();
            }

            @Override
            public Object getItem(int arg0) {
                return null;
            }

            @Override
            public long getItemId(int arg0) {
                return 0;
            }

            @Override
            public View getView(int arg0, View arg1, ViewGroup arg2) {
                arg1 = View.inflate(MainActivity.this,R.layout.item,null);
                TextView text_title = (TextView)arg1.findViewById(R.id.text_title);
                text_title.setText(asd.get(arg0));
                return arg1;
            }
            
        }
        private void Data() {
            asd = new ArrayList<String>();
            for (int i = 0; i < qwe; i++) {
            asd.add("q"+i);
            }
        }

    }

  • 相关阅读:
    利用WinCE的精准计时函数来输出pwm信号以便控制舵机
    leafletjs旋转marker
    centos7 NodeJs安装问题:Error: Cannot find module '../lib/utils/unsupported.js'
    Django 自定义存储上传文件的文件名
    后端开发不会前端之表格插件的使用
    Django项目部署之sqlite版本升级
    SQL 循环30日
    SSRS 报表 报表迁移
    SQL SERVER中求上月、本月和下月的第一天和最后一天
    SSRS 报表 日期类表达式
  • 原文地址:https://www.cnblogs.com/3674-it/p/5551080.html
Copyright © 2011-2022 走看看