コード例 #1
0
  @SuppressWarnings("MagicConstant")
  private IcsLinearLayout findOrInitializeLayout(final View convertView) {
    IcsLinearLayout layout;

    if (convertView == null || !(convertView instanceof IcsLinearLayout)) {
      layout = new IcsLinearLayout(context, null);
      if (listView.isDebugging()) layout.setBackgroundColor(Color.parseColor("#83F27B"));

      layout.setShowDividers(IcsLinearLayout.SHOW_DIVIDER_MIDDLE);
      layout.setDividerDrawable(
          context.getResources().getDrawable(R.drawable.item_divider_horizontal));

      layout.setLayoutParams(
          new AbsListView.LayoutParams(
              AbsListView.LayoutParams.MATCH_PARENT, AbsListView.LayoutParams.WRAP_CONTENT));
    } else layout = (IcsLinearLayout) convertView;

    // Clear all layout children before starting
    for (int j = 0; j < layout.getChildCount(); j++) {
      IcsLinearLayout tempChild = (IcsLinearLayout) layout.getChildAt(j);
      linearLayoutPool.put(tempChild);
      for (int k = 0; k < tempChild.getChildCount(); k++) viewPool.put(tempChild.getChildAt(k));
      tempChild.removeAllViews();
    }
    layout.removeAllViews();

    return layout;
  }
コード例 #2
0
  @SuppressWarnings("MagicConstant")
  private IcsLinearLayout findOrInitializeChildLayout(
      final LinearLayout parentLayout, final int childIndex) {
    IcsLinearLayout childLayout = (IcsLinearLayout) parentLayout.getChildAt(childIndex);

    if (childLayout == null) {
      childLayout = linearLayoutPool.get();
      childLayout.setOrientation(LinearLayout.VERTICAL);

      if (listView.isDebugging()) childLayout.setBackgroundColor(Color.parseColor("#837BF2"));

      childLayout.setShowDividers(IcsLinearLayout.SHOW_DIVIDER_MIDDLE);
      childLayout.setDividerDrawable(
          context.getResources().getDrawable(R.drawable.item_divider_vertical));

      childLayout.setLayoutParams(
          new AbsListView.LayoutParams(
              AbsListView.LayoutParams.WRAP_CONTENT, AbsListView.LayoutParams.MATCH_PARENT));
      parentLayout.addView(childLayout);
    }

    return childLayout;
  }