Ejemplo n.º 1
0
  private void initView() {
    mTitleBar = (TitleBar) findViewById(R.id.title_bar);
    mTitleBar.setTitle("预约服务");

    mListView = (PullToRefreshListView) findViewById(R.id.listview);
    mListView.setMode(Mode.PULL_FROM_END);
    mListView.setOnRefreshListener(
        new OnRefreshListener2<ListView>() {

          @Override
          public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {}

          @Override
          public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
            //				loadData();
            //				mListView.onRefreshComplete();
            new GetDataTask().execute();
          }
        });

    //		mListView.setOnItemClickListener(new OnItemClickListener() {
    //
    //			@Override
    //			public void onItemClick(AdapterView<?> parent, View view,
    //					int position, long id) {
    //				startActivity(new Intent(ReserveServiceActivity.this, CommitReserveMsgActivity.class));
    //			}
    //		});

    mListView.setAdapter(mAdapter);
  }
Ejemplo n.º 2
0
  private void setListener() {

    mListView.getLoadingLayoutProxy(false, true).setPullLabel("上拉加载更多");
    mListView.getLoadingLayoutProxy(false, true).setReleaseLabel("松开加载");
    mListView.getLoadingLayoutProxy(false, true).setRefreshingLabel("正在加载...");
    if (mOnItemClickListener != null) mListView.setOnItemClickListener(mOnItemClickListener);
    //		mListView.setOnRefreshListener(new OnRefreshListener2<ListView>() {
    //			@Override
    //			public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
    //
    //			}
    //
    //			@Override
    //			public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
    //				if (mRefreshLisenter != null) {
    //					mRefreshLisenter.onRefresh();
    //				}
    //				mListView.onRefreshComplete();
    //				mAdapter.notifyDataSetChanged();
    //			}
    //		});

    mListView.setOnRefreshListener(
        new OnRefreshListener<ListView>() {

          @Override
          public void onRefresh(PullToRefreshBase<ListView> refreshView) {
            int size = mAdapter.getCount();
            new GetDataTask().execute();
            refreshView.getRefreshableView().setSelection(size);
          }
        });

    // 添加滑动到底部的监听器
    //		mListView.setOnLastItemVisibleListener(new OnLastItemVisibleListener() {
    //
    //            @Override
    //            public void onLastItemVisible() {
    //            	if (mRefreshLisenter != null) {
    //					mRefreshLisenter.onRefresh();
    //				}
    //            	mListView.onRefreshComplete();
    //				mAdapter.notifyDataSetChanged();
    //            }
    //        });

    mListView.isScrollingWhileRefreshingEnabled(); // 看刷新时是否允许滑动
    // 在刷新时允许继续滑动
    mListView.setScrollingWhileRefreshingEnabled(true);
    mListView.setMode(PullToRefreshBase.Mode.BOTH); // 设置刷新模式:下拉、上拉或两者皆可
  }