Java Code Examples for android.widget.TableRow#removeViewAt()

The following examples show how to use android.widget.TableRow#removeViewAt() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TableLayout.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
private void addChild(AndroidViewComponent child) {
  int row = child.Row();
  int col = child.Column();
  if (row == ComponentConstants.DEFAULT_ROW_COLUMN ||
      col == ComponentConstants.DEFAULT_ROW_COLUMN) {
    addChildLater(child);

  } else {

    if (row >= 0 && row < numRows) {
      if (col >= 0 && col < numColumns) {
        TableRow tableRow = (TableRow) layoutManager.getChildAt(row);
        tableRow.removeViewAt(col);
        View cellView = child.getView();
        tableRow.addView(cellView, col, cellView.getLayoutParams());
      } else {
        Log.e("TableLayout", "Child has illegal Column property: " + child);
      }
    } else {
      Log.e("TableLayout", "Child has illegal Row property: " + child);
    }
  }
}
 
Example 2
Source File: TimetableView.java    From TimetableView with Apache License 2.0 5 votes vote down vote up
public void setHeaderHighlight(int idx) {
    if(idx < 0)return;
    TableRow row = (TableRow) tableHeader.getChildAt(0);
    View element = row.getChildAt(idx);
    if(highlightMode == HighlightMode.COLOR) {
        TextView tx = (TextView)element;
        tx.setTextColor(Color.parseColor("#FFFFFF"));
        tx.setBackgroundColor(headerHighlightColor);
        tx.setTypeface(null, Typeface.BOLD);
        tx.setTextSize(TypedValue.COMPLEX_UNIT_DIP, DEFAULT_HEADER_HIGHLIGHT_FONT_SIZE_DP);
    }
    else if(highlightMode == HighlightMode.IMAGE){
        RelativeLayout outer = new RelativeLayout(context);
        outer.setLayoutParams(createTableRowParam(cellHeight));
        ImageView iv = new ImageView(context);
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(headerHighlightImageSize,headerHighlightImageSize);
        params.addRule(RelativeLayout.CENTER_IN_PARENT,RelativeLayout.TRUE);
        iv.setLayoutParams(params);
        iv.setScaleType(ImageView.ScaleType.CENTER_CROP);

        row.removeViewAt(idx);
        outer.addView(iv);
        row.addView(outer,idx);

        if(headerHighlightImage != null) {
            iv.setImageDrawable(headerHighlightImage);
        }

    }
}