Code example for TableRow

Methods: addViewsetDescendantFocusabilitysetGravity, setClickable

0
  } 
  private float dipToPx(float dip) {
    return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dip, this.getResources().getDisplayMetrics());
  } 
  private void addHeaderRow(Context context) {
    this.headerRow = new TableRow(context);
    this.headerRow.setClickable(true);
    this.headerRow.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
    this.headerRow.setGravity(Gravity.CENTER_VERTICAL);
     
    this.expando = new ImageView(context);
    int eightDip = (int)dipToPx(8);
    TableRow.LayoutParams p = new TableRow.LayoutParams(0);
    p.setMargins(eightDip, eightDip, eightDip, eightDip);
    this.expando.setImageResource(this.getCollapseDrawable());
    this.headerRow.addView(this.expando, p);
     
    this.label = new TextView(context, null, this.getCaptionAppearance());
    this.label.setText(this.getCaption());
    this.headerRow.addView(this.label, new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
     
    super.addView(this.headerRow, -1, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
     
  } 
  private void addContentRow(Context context) {