Exemple #1
0
  @Override
  public void setAdapter(ListAdapter adapter) {
    // make sure XListViewFooter is the last footer view, and only add once.
    if (mIsFooterReady == false) {
      mIsFooterReady = true;
      addFooterView(mFooterView);
    }
    // zzw

    if (adapter instanceof AdpCommunityListView) {
      mCommunityAdapter = (AdpCommunityListView) adapter;
      ((AdpCommunityListView) adapter).setHorizontalSpacing(horizontalSpacing);
      ((AdpCommunityListView) adapter).setColumnsNum(numColumns);
      ((AdpCommunityListView) adapter).setColumnsWidth(columnsWidth);
    }
    super.setAdapter(adapter);
  }
Exemple #2
0
  /** 该函数确定图片存放在View里面的范围 */
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    Log.d("zzw", "onMeasure:" + numColumns + " " + horizontalSpacing);

    if (numColumns != 0) {
      columnsWidth =
          (getMeasuredWidth()
                  - getPaddingLeft()
                  - getPaddingRight()
                  - 2 * getResources().getDimensionPixelOffset(R.dimen.marginleft)
                  - 2 * getResources().getDimensionPixelOffset(R.dimen.item_border)
                  - 2 * getResources().getDimensionPixelOffset(R.dimen.head_width)
                  - numColumns * 2 * horizontalSpacing)
              / numColumns;
      Log.d("zzw", "onMeasure:" + columnsWidth);
      if (mCommunityAdapter != null) {
        ((AdpCommunityListView) mCommunityAdapter).setColumnsWidth(columnsWidth);
      }
    }
  }