コード例 #1
0
        @Override
        public void handleMessage(Message msg) {
          switch (msg.what) {
            case LOADING:
              // mPbLoading.setVisibility(View.VISIBLE);
              mIvEmpty.setVisibility(View.GONE);
              mLvData.setVisibility(View.VISIBLE);
              break;
            case FINISH:
              mLvData.finishRefreshing();

              mPbLoading.setVisibility(View.GONE);
              if (mDatas.isEmpty()) {
                mLvData.setVisibility(View.GONE);
                mIvEmpty.setVisibility(View.VISIBLE);
              } else {
                mLvData.setVisibility(View.VISIBLE);
                mIvEmpty.setVisibility(View.GONE);

                adapter.notifyDataSetChanged();
                if (mIsFirst) {
                  mLvData.smoothScrollToPosition(0);
                  mIsFirst = false;
                }
              }
              break;
          }
        }
コード例 #2
0
  private void initView() {
    setContentView(R.layout.activity_android_black);

    mLvData = (RefreshListView) findViewById(R.id.lv_black_data);
    mLvData.isEnableRefreshFoot(true);
    mLvData.isEnableRefreshHead(true);
    mIvEmpty = (ImageView) findViewById(R.id.iv_black_empty);
    mBtAdd = (Button) findViewById(R.id.bt_black_add);

    mPbLoading = (ProgressBar) findViewById(R.id.pb_black_loading);

    adapter = new BlackAdapter();
    mLvData.setAdapter(adapter);
    initPopWindow();
    initDialog();
  }
コード例 #3
0
  private void initEvent() {
    mBtAdd.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (mPopMenu != null && mPopMenu.isShowing()) {
              mPopMenu.dismiss();
            } else {
              mPopMenu.showAsDropDown(v);
              mViewPop.startAnimation(animation);
            }
          }
        });
    mLvData.setOnRefreshingDataListener(
        new RefreshListView.OnRefreshingDataListener() {
          @Override
          public void onHeadRefreshing() {
            mDatas.clear();
            initData();
          }

          @Override
          public void onFooterFreshing() {
            initData();
          }
        });

    //        mLvData.setOnScrollListener(new AbsListView.OnScrollListener() {
    //            @Override
    //            public void onScrollStateChanged(AbsListView view, int scrollState) {
    //                if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE) {
    //                    int lastVisiblePosition = mLvData.getLastVisiblePosition();
    //                    System.out.println("lastVisiblePosition: " + lastVisiblePosition);
    //                    System.out.println(mDatas.size() - 1);
    //                    if (lastVisiblePosition >= (mDatas.size() - 1)) {
    //                        initData();
    //                    }
    //                }
    //            }
    //
    //            @Override
    //            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount,
    // int totalItemCount) {
    //
    //            }
    //        });
  }