• android:为ListView 添加自定义头部和尾部,上拉主动加载 .(引)


    1.加头尾部


    (1)定自义一个xml布局 my_headview.xml


    在Activity类里找到这个自定义布局,并添加到头部


    LinearLayout  hearderViewLayout = (LinearLayout) LayoutInflater.(
                            xwActivity.this).inflate(R.layout.my_headview, null);


    listview.addHeaderView(hearderViewLayout);


    (2)定自义一个xml布局 my_footview.xml


    LinearLayout  footViewLayout = (LinearLayout) LayoutInflater.(
                            xwActivity.this).inflate(R.layout.my_footview, null);


    listview.addFooterView(footerViewLayout);


    (3)重视事务


    listview必然会有Adapter,参加头尾部,必须在参加Adapter之前!


    listview.addHeaderView(hearderViewLayout);


    listview.addFooterView(footerViewLayout);


    listview.setAdapter(myAdapter);



    1.加上拉到尾部的监听件件


    listview.setOnScrollListener(new OnScrollListener() {
                public void onScrollStateChanged(AbsListView view, int scrollState) {
                    switch (scrollState) {
                    case OnScrollListener.SCROLL_STATE_IDLE: // 当不迁移转变时
                        // 断定迁移转变到底部
                        if (view.getLastVisiblePosition() == (view.getCount() - 1)) {

                           //在这里添加操纵

                        }
                        break;
                    }
                }

                public void onScroll(AbsListView view, int firstVisibleItem,
                        int visibleItemCount, int totalItemCount) {

                }
            });

    文章引自:http://blog.csdn.net/wangwei_cq/article/details/9383759

  • 相关阅读:
    geoserver发布mysql表数据
    geoserver1
    geoserver
    快速搭建arcgis以及cesium环境
    openlayers和cesium实现地图二三维切换
    记Mysql类型引起的BUG
    OpenLayers 图层(Layers) 详解
    基于TrueLicense实现产品License验证功能
    第七章
    第六周进度报告
  • 原文地址:https://www.cnblogs.com/xiaoerlang90/p/4165262.html
Copyright © 2020-2023  润新知