android.widget.TableRow Java Examples

The following examples show how to use android.widget.TableRow. 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: ViewUtil.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
public static void setChildWidthForTableLayout(View view, int width) {
  Object layoutParams = view.getLayoutParams();
  if (layoutParams instanceof TableRow.LayoutParams) {
    TableRow.LayoutParams tableLayoutParams = (TableRow.LayoutParams) layoutParams;
    switch (width) {
      case Component.LENGTH_PREFERRED:
        tableLayoutParams.width = TableRow.LayoutParams.WRAP_CONTENT;
        break;
      case Component.LENGTH_FILL_PARENT:
        tableLayoutParams.width = TableRow.LayoutParams.FILL_PARENT;
        break;
      default:
        tableLayoutParams.width = calculatePixels(view, width);
        break;
    }
    view.requestLayout();
  } else {
    Log.e("ViewUtil", "The view does not have table layout parameters");
  }
}
 
Example #2
Source File: PersonDetail.java    From kute with Apache License 2.0 6 votes vote down vote up
public Boolean handleOtherDetailsDropdown(Boolean is_otherdetail_dropdown, ImageButton icon, final TableRow other_details_text) {
    if (is_otherdetail_dropdown) {
        other_details_text.setVisibility(View.GONE);
        icon.setImageResource(R.drawable.ic_arrow_drop_down_black_24dp);
        return false;
    } else {
        other_details_text.setVisibility(View.VISIBLE);
        icon.setImageResource(R.drawable.ic_arrow_drop_up_black_24dp);
        //Adjusting the scrollview for smaller screens
        scroll_view.post(new Runnable() {
            @Override
            public void run() {
                scroll_view.scrollTo(0, other_details_text.getBottom());
            }
        });
        return true;
    }
}
 
Example #3
Source File: RecipeActivity.java    From app-indexing with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.ingredients_fragment, container, false);

    this.recipe = ((RecipeActivity) getActivity()).mRecipe;

    TableLayout table = (TableLayout) rootView.findViewById(R.id.ingredientsTable);
    for (Recipe.Ingredient ingredient : recipe.getIngredients()) {
        TableRow row = (TableRow) inflater.inflate(R.layout.ingredients_row, null);
        ((TextView) row.findViewById(R.id.attrib_name)).setText(ingredient.getAmount());
        ((TextView) row.findViewById(R.id.attrib_value)).setText(ingredient
                .getDescription());
        table.addView(row);
    }

    return rootView;
}
 
Example #4
Source File: MainActivity.java    From rpicheck with MIT License 6 votes vote down vote up
private View createNetworkRow(NetworkInterfaceInformation interfaceInformation) {
    final TableRow tempRow = new TableRow(this);
    tempRow.addView(createTextView(interfaceInformation.getName()));
    CharSequence statusText;
    if (interfaceInformation.isHasCarrier()) {
        statusText = getText(R.string.network_status_up);
    } else {
        statusText = getText(R.string.network_status_down);
    }
    tempRow.addView(createTextView(statusText.toString()));
    if (interfaceInformation.getIpAdress() != null) {
        tempRow.addView(createTextView(interfaceInformation.getIpAdress()));
    } else {
        tempRow.addView(createTextView(" - "));
    }
    if (interfaceInformation.getWlanInfo() != null) {
        final WlanBean wlan = interfaceInformation.getWlanInfo();
        tempRow.addView(createTextView(FormatHelper.formatPercentage(wlan.getSignalLevel())));
        tempRow.addView(createTextView(FormatHelper.formatPercentage(wlan.getLinkQuality())));
    } else {
        tempRow.addView(createTextView(" - "));
        tempRow.addView(createTextView(" - "));
    }
    return tempRow;
}
 
Example #5
Source File: TableFragment.java    From openScale with GNU General Public License v3.0 6 votes vote down vote up
public void updateOnView(List<ScaleMeasurement> scaleMeasurementList)
{
    tableHeaderView.removeAllViews();

    final int iconHeight = pxImageDp(20);
    ArrayList<MeasurementView> visibleMeasurements = new ArrayList<>();

    for (MeasurementView measurement : measurementViews) {
        if (!measurement.isVisible() || measurement instanceof UserMeasurementView) {
            continue;
        }


        ImageView headerIcon = new ImageView(tableView.getContext());
        headerIcon.setImageDrawable(measurement.getIcon());
        headerIcon.setColorFilter(ColorUtil.getTintColor(tableView.getContext()));
        headerIcon.setLayoutParams(new TableRow.LayoutParams(0, iconHeight, 1));
        headerIcon.setScaleType(ImageView.ScaleType.CENTER_INSIDE);

        tableHeaderView.addView(headerIcon);

        visibleMeasurements.add(measurement);
    }

    adapter.setMeasurements(visibleMeasurements, scaleMeasurementList);
}
 
Example #6
Source File: GameSelector.java    From Simple-Solitaire with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Starts the clicked game. This uses the total index position of the clicked view to get the
 * game.
 *
 * @param view The clicked view.
 */
private void startGame(View view) {
    TableRow row = (TableRow) view.getParent();
    TableLayout table = (TableLayout) row.getParent();
    ArrayList<Integer> orderedList = lg.getOrderedGameList();
    int index = indexes.get(table.indexOfChild(row) * menuColumns + row.indexOfChild(view));
    index = orderedList.indexOf(index);

    //avoid loading two games at once when pressing two buttons at once
    if (prefs.getSavedCurrentGame() != DEFAULT_CURRENT_GAME) {
        return;
    }

    prefs.saveCurrentGame(index);
    Intent intent = new Intent(getApplicationContext(), GameManager.class);
    intent.putExtra(GAME, index);
    startActivityForResult(intent, 0);
}
 
Example #7
Source File: AccessConditionDecoder.java    From MifareClassicTool with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Add full access condition information about one sector to the layout
 * table. (This method will trigger
 * {@link #addBlockAC(byte[][], boolean)} and
 * {@link #addSectorTrailerAC(byte[][])}
 * @param acMatrix Matrix of access conditions bits (C1-C3) where the first
 * dimension is the "C" parameter (C1-C3, Index 0-2) and the second
 * dimension is the block number
 * (Block0-Block2 + Sector Trailer, Index 0-3).
 * @param sectorHeader The sector header to display (e.g. "Sector: 0").
 * @param hasMoreThan4Blocks True for the last 8 sectors
 * of a MIFARE Classic 4K tag.
 * @see #addBlockAC(byte[][], boolean)
 * @see #addSectorTrailerAC(byte[][])
 */
private void addSectorAC(byte[][] acMatrix, String sectorHeader,
        boolean hasMoreThan4Blocks) {
    // Add sector header.
    TextView header = new TextView(this);
    header.setText(Common.colorString(sectorHeader,
            getResources().getColor(R.color.blue)),
            BufferType.SPANNABLE);
    TableRow tr = new TableRow(this);
    tr.setLayoutParams(new LayoutParams(
            LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT));
    tr.addView(header);
    mLayout.addView(tr, new LayoutParams(
            LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT));
    // Add Block 0-2.
    addBlockAC(acMatrix, hasMoreThan4Blocks);
    // Add Sector Trailer.
    addSectorTrailerAC(acMatrix);
}
 
Example #8
Source File: RadioSectionFragment.java    From satstat with GNU General Public License v3.0 6 votes vote down vote up
protected void showCellCdma(CellTowerCdma cellTower) {
	TableRow row = (TableRow) mainActivity.getLayoutInflater().inflate(R.layout.ril_cdma_list_item, null);
	TextView type = (TextView) row.findViewById(R.id.type);
	TextView sid = (TextView) row.findViewById(R.id.sid);
	TextView nid = (TextView) row.findViewById(R.id.nid);
	TextView bsid = (TextView) row.findViewById(R.id.bsid);
	TextView dbm = (TextView) row.findViewById(R.id.dbm);

	type.setTextColor(rilCdmaCells.getContext().getResources().getColor(getColorFromGeneration(cellTower.getGeneration())));
	type.setText(rilCdmaCells.getContext().getResources().getString(R.string.smallDot));

	sid.setText(formatCellData(rilCdmaCells.getContext(), null, cellTower.getSid()));

	nid.setText(formatCellData(rilCdmaCells.getContext(), null, cellTower.getNid()));

	bsid.setText(formatCellData(rilCdmaCells.getContext(), null, cellTower.getBsid()));

	dbm.setText(formatCellDbm(rilCdmaCells.getContext(), null, cellTower.getDbm()));

	rilCdmaCells.addView(row,new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
}
 
Example #9
Source File: PageHandler.java    From SI with BSD 2-Clause "Simplified" License 6 votes vote down vote up
protected void appendRow( String value ){

        // create table row
        TableLayout tb = (TableLayout)findViewById(R.id.control_table_layout);
        TableRow tableRow = new TableRow(this);
        tableRow.setLayoutParams(tableLayout);

        // get current time
        long time = System.currentTimeMillis();
        SimpleDateFormat dayTime = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        String cur_time = dayTime.format(new Date(time));

        // set Text on TextView
        TextView tv_left = new TextView(this);
        tv_left.setText( cur_time );
        tv_left.setLayoutParams( tableRowLayout );
        tableRow.addView( tv_left );

        TextView tv_right = new TextView(this);
        tv_right.setText( value );
        tv_right.setLayoutParams( tableRowLayout );
        tableRow.addView( tv_right );

        // set table rows on table
        tb.addView(tableRow);
    }
 
Example #10
Source File: TimetableView.java    From TimetableView with Apache License 2.0 6 votes vote down vote up
private void createTableHeader() {
    TableRow tableRow = new TableRow(context);
    tableRow.setLayoutParams(createTableLayoutParam());

    for (int i = 0; i < columnCount; i++) {
        TextView tv = new TextView(context);
        if (i == 0) {
            tv.setLayoutParams(createTableRowParam(sideCellWidth, cellHeight));
        } else {
            tv.setLayoutParams(createTableRowParam(cellHeight));
        }
        tv.setTextColor(getResources().getColor(R.color.colorHeaderText));
        tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, DEFAULT_HEADER_FONT_SIZE_DP);
        tv.setText(headerTitle[i]);
        tv.setGravity(Gravity.CENTER);

        tableRow.addView(tv);
    }
    tableHeader.addView(tableRow);
}
 
Example #11
Source File: JoggingTabFragment.java    From grblcontroller with GNU General Public License v3.0 6 votes vote down vote up
private void SetCustomButtons(View view){
    TableRow customButtonLayout = view.findViewById(R.id.custom_button_layout);
    if(customButtonLayout == null) return;

    if(sharedPref.getBoolean(getString(R.string.preference_enable_custom_buttons), false)){
        customButtonLayout.setVisibility(View.VISIBLE);

        for(int resourceId: new Integer[]{R.id.custom_button_1, R.id.custom_button_2, R.id.custom_button_3, R.id.custom_button_4}){
            IconButton iconButton = view.findViewById(resourceId);

            if(resourceId == R.id.custom_button_1) iconButton.setText(sharedPref.getString(getString(R.string.preference_custom_button_one), getString(R.string.text_value_na)));
            if(resourceId == R.id.custom_button_2) iconButton.setText(sharedPref.getString(getString(R.string.preference_custom_button_two), getString(R.string.text_value_na)));
            if(resourceId == R.id.custom_button_3) iconButton.setText(sharedPref.getString(getString(R.string.preference_custom_button_three), getString(R.string.text_value_na)));
            if(resourceId == R.id.custom_button_4) iconButton.setText(sharedPref.getString(getString(R.string.preference_custom_button_four), getString(R.string.text_value_na)));

            iconButton.setOnLongClickListener(this);
            iconButton.setOnClickListener(this);
        }
    }else{
        customButtonLayout.setVisibility(View.GONE);
    }
}
 
Example #12
Source File: NineGridView.java    From webrtc_android with MIT License 6 votes vote down vote up
public void setAdapter(BaseAdapter adapter) {
    if (adapter != null) {
        if (adapter.getCount() < this.rowNum * this.colNum) {
            throw new IllegalArgumentException("The view count of adapter is less than this gridview's items");
        }
        this.removeAllViews();
        for (int y = 0; y < rowNum; ++y) {
            TableRow row = new TableRow(context);
            row.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f));
            for (int x = 0; x < colNum; ++x) {
                View view = adapter.getView(y * colNum + x, this, row);
                row.addView(view, new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f));
            }
            this.addView(row);
        }
    }
    this.adapter = adapter;
}
 
Example #13
Source File: ReplayStepFragment.java    From SoloPi with Apache License 2.0 6 votes vote down vote up
ResultItemViewHolder(View v) {
    super(v);
    mActionName = (TextView) v.findViewById(R.id.text_case_result_step_title);
    mActionParam = (TextView) v.findViewById(R.id.text_case_result_step_param);
    mPrepareActions = (TextView) v.findViewById(R.id.text_case_result_step_prepare);
    mStatus = (TextView) v.findViewById(R.id.text_case_result_step_status);


    mParamRow = (TableRow) v.findViewById(R.id.row_case_result_step_param);
    mPrepareRow = (TableRow) v.findViewById(R.id.row_case_result_step_prepare);
    mNodeRow = (TableRow) v.findViewById(R.id.row_case_result_step_node);
    mCaptureRow = (TableRow) v.findViewById(R.id.row_case_result_step_capture);

    mTargetNode = mNodeRow.findViewById(R.id.text_case_result_step_target_node);
    mFindNode = mNodeRow.findViewById(R.id.text_case_result_step_find_node);

    mTargetCapture = (ImageView) mCaptureRow.findViewById(R.id.img_case_result_target);
    mFindCapture = (ImageView) mCaptureRow.findViewById(R.id.img_case_result_find);

    mTargetNode.setOnClickListener(this);
    mFindNode.setOnClickListener(this);
    mTargetCapture.setOnClickListener(this);
    mFindCapture.setOnClickListener(this);
}
 
Example #14
Source File: ColorPickerPalette.java    From FastAccess with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Appends a swatch to the end of the row for even-numbered rows (starting with row 0),
 * to the beginning of a row for odd-numbered rows.
 */
private static void addSwatchToRow(TableRow row, View swatch, int rowNumber) {
    if (rowNumber % 2 == 0) {
        row.addView(swatch);
    } else {
        row.addView(swatch, 0);
    }
}
 
Example #15
Source File: MainActivityTest.java    From Simple-Accounting with GNU General Public License v3.0 5 votes vote down vote up
protected TableRow createNewRow(String credit, String debit) {
    fab.callOnClick();

    TableRow row = (TableRow) table.getChildAt(table.getEditableRow());
    EditText creditEditable = row.findViewById(R.id.editCredit);
    EditText debitEditable = row.findViewById(R.id.editDebit);

    creditEditable.setText(credit);
    debitEditable.setText(debit);

    table.editableRowToView();

    return row;
}
 
Example #16
Source File: ColorPickerPalette.java    From ColorPicker with Apache License 2.0 5 votes vote down vote up
/**
 * Adds swatches to table in a serpentine format.
 */
public void drawPalette(int[] colors, int selectedColor, String[] colorContentDescriptions,
        int width, int strokeColor) {
    if (colors == null) {
        return;
    }

    this.removeAllViews();
    int tableElements = 0;
    int rowElements = 0;
    int rowNumber = 0;

    // Fills the table with swatches based on the array of colors.
    TableRow row = createTableRow();
    for (int color : colors) {
        View colorSwatch = createColorSwatch(color, selectedColor, width, strokeColor);
        setSwatchDescription(rowNumber, tableElements, rowElements, color == selectedColor,
                colorSwatch, colorContentDescriptions);
        addSwatchToRow(row, colorSwatch, rowNumber, mBackwardsOrder);

        tableElements++;
        rowElements++;
        if (rowElements == mNumColumns) {
            addView(row);
            row = createTableRow();
            rowElements = 0;
            rowNumber++;
        }
    }

    // Create blank views to fill the row if the last row has not been filled.
    if (rowElements > 0) {
        while (rowElements != mNumColumns) {
            addSwatchToRow(row, createBlankSpace(), rowNumber, mBackwardsOrder);
            rowElements++;
        }
        addView(row);
    }
}
 
Example #17
Source File: ColorPickerPalette.java    From Swiftnotes with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a blank space to fill the row
 */
private ImageView createBlankSpace() {
    ImageView view = new ImageView(getContext());
    TableRow.LayoutParams params = new TableRow.LayoutParams(mSwatchLength, mSwatchLength);
    params.setMargins(mMarginSize, mMarginSize, mMarginSize, mMarginSize);
    view.setLayoutParams(params);

    return view;
}
 
Example #18
Source File: ColorPickerPalette.java    From KAM with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a blank space to fill the row.
 */
private ImageView createBlankSpace() {
    ImageView view = new ImageView(getContext());
    TableRow.LayoutParams params = new TableRow.LayoutParams(mSwatchLength, mSwatchLength);
    params.setMargins(mMarginSize, mMarginSize, mMarginSize, mMarginSize);
    view.setLayoutParams(params);
    return view;
}
 
Example #19
Source File: ColorPickerPalette.java    From FastAccess with GNU General Public License v3.0 5 votes vote down vote up
private TableRow createTableRow() {
    TableRow row = new TableRow(getContext());
    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    row.setLayoutParams(params);
    return row;
}
 
Example #20
Source File: ScoresActivity.java    From tedroid with Apache License 2.0 5 votes vote down vote up
/** @return una fila con el texto de que no hay puntajes. */
private TableRow emptyScoresRow() {
    TableRow row = new TableRow(this);
    TextView noScoresText = new TextView(this);
    noScoresText.setText(R.string.no_scores_message);
    applyPrimaryStyleTo(noScoresText);
    row.addView(noScoresText);
    return row;
}
 
Example #21
Source File: StretchViewActivity.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
public void showTable() {
    TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(
            TableRow.LayoutParams.MATCH_PARENT,
            TableRow.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER;
    layoutParams.leftMargin = 30;
    layoutParams.bottomMargin = 10;
    layoutParams.topMargin = 10;

    for (int i = 0; i < 40; i++) {
        TableRow tableRow = new TableRow(this);
        TextView textView = new TextView(this);
        textView.setText("Test stretch scroll view " + i);
        textView.setTextSize(20);
        textView.setPadding(15, 15, 15, 15);

        tableRow.addView(textView, layoutParams);
        if (i % 2 != 0) {
            tableRow.setBackgroundColor(Color.LTGRAY);
        } else {
            tableRow.setBackgroundColor(Color.WHITE);
        }

        final int n = i;
        tableRow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(StretchViewActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show();
            }
        });

        mMainLayout.addView(tableRow);
    }
}
 
Example #22
Source File: ColorPickerPalette.java    From KAM with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a color swatch.
 */
private ColorPickerSwatch createColorSwatch(int color, int selectedColor) {
    ColorPickerSwatch view = new ColorPickerSwatch(getContext(), color,
            color == selectedColor, mOnColorSelectedListener);
    TableRow.LayoutParams params = new TableRow.LayoutParams(mSwatchLength, mSwatchLength);
    params.setMargins(mMarginSize, mMarginSize, mMarginSize, mMarginSize);
    view.setLayoutParams(params);
    return view;
}
 
Example #23
Source File: ColorPickerPalette.java    From Augendiagnose with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adds swatches to table in a serpentine format.
 *
 * @param colors        The colors to be added.
 * @param selectedColor The preselected color.
 */
public final void drawPalette(@Nullable final int[] colors, final int selectedColor) {
	if (colors == null) {
		return;
	}

	this.removeAllViews();
	int tableElements = 0;
	int rowElements = 0;
	int rowNumber = 0;

	// Fills the table with swatches based on the array of colors.
	TableRow row = createTableRow();
	for (int color : colors) {
		tableElements++;

		View colorSwatch = createColorSwatch(color, selectedColor);
		setSwatchDescription(rowNumber, tableElements, rowElements, color == selectedColor,
				colorSwatch);
		addSwatchToRow(row, colorSwatch);

		rowElements++;
		if (rowElements == mNumColumns) {
			addView(row);
			row = createTableRow();
			rowElements = 0;
			rowNumber++;
		}
	}

	// Create blank views to fill the row if the last row has not been filled.
	if (rowElements > 0) {
		while (rowElements != mNumColumns) {
			addSwatchToRow(row, createBlankSpace());
			rowElements++;
		}
		addView(row);
	}
}
 
Example #24
Source File: ColorPickerPalette.java    From privacy-friendly-ludo with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a color swatch.
 */
private ColorPickerSwatch createColorSwatch(int color, int selectedColor) {
    ColorPickerSwatch view = new ColorPickerSwatch(getContext(), color,
            color == selectedColor, mOnColorSelectedListener);
    TableRow.LayoutParams params = new TableRow.LayoutParams(mSwatchLength, mSwatchLength);
    params.setMargins(mMarginSize, mMarginSize, mMarginSize, mMarginSize);
    view.setLayoutParams(params);
    return view;
}
 
Example #25
Source File: StretchViewActivity.java    From PullScrollView with Apache License 2.0 5 votes vote down vote up
public void showTable() {
    TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(
            TableRow.LayoutParams.MATCH_PARENT,
            TableRow.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER;
    layoutParams.leftMargin = 30;
    layoutParams.bottomMargin = 10;
    layoutParams.topMargin = 10;

    for (int i = 0; i < 40; i++) {
        TableRow tableRow = new TableRow(this);
        TextView textView = new TextView(this);
        textView.setText("Test stretch scroll view " + i);
        textView.setTextSize(20);
        textView.setPadding(15, 15, 15, 15);

        tableRow.addView(textView, layoutParams);
        if (i % 2 != 0) {
            tableRow.setBackgroundColor(Color.LTGRAY);
        } else {
            tableRow.setBackgroundColor(Color.WHITE);
        }

        final int n = i;
        tableRow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(StretchViewActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show();
            }
        });

        mMainLayout.addView(tableRow);
    }
}
 
Example #26
Source File: ColorPickerPalette.java    From privacy-friendly-ludo with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Appends a swatch to the end of the row for even-numbered rows (starting with row 0),
 * to the beginning of a row for odd-numbered rows.
 */
private static void addSwatchToRow(TableRow row, View swatch, int rowNumber) {
    if (rowNumber % 2 == 0) {
        row.addView(swatch);
    } else {
        row.addView(swatch, 0);
    }
}
 
Example #27
Source File: PulldownViewActivity.java    From PullScrollView with Apache License 2.0 5 votes vote down vote up
public void showTable() {
    TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(
            TableRow.LayoutParams.MATCH_PARENT,
            TableRow.LayoutParams.WRAP_CONTENT);
    layoutParams.gravity = Gravity.CENTER;
    layoutParams.leftMargin = 30;
    layoutParams.bottomMargin = 10;
    layoutParams.topMargin = 10;

    for (int i = 0; i < 30; i++) {
        TableRow tableRow = new TableRow(this);
        TextView textView = new TextView(this);
        textView.setText("Test pull down scroll view " + i);
        textView.setTextSize(20);
        textView.setPadding(15, 15, 15, 15);

        tableRow.addView(textView, layoutParams);
        if (i % 2 != 0) {
            tableRow.setBackgroundColor(Color.LTGRAY);
        } else {
            tableRow.setBackgroundColor(Color.WHITE);
        }

        final int n = i;
        tableRow.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(PulldownViewActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show();
            }
        });

        mMainLayout.addView(tableRow);
    }
}
 
Example #28
Source File: DisplayModelActivity.java    From nosey with Apache License 2.0 5 votes vote down vote up
public void addModelFieldHeaders(TableLayout table, Inspector.ModelMapInspector inspector) {
    // Get Fields for a given model
    model.getDeclaredFields();
    Field[] allFields = model.getDeclaredFields();
    Arrays.sort(allFields, new MemberComparator<Field>());

    // Add the field headers to the table row
    TableRow headers = new ColoredTableRow(this, RowColors.getColor(table.getChildCount()));
    for (Field field : allFields) {
        if (!Modifier.isStatic(field.getModifiers())) {
            headers.addView(new CellTextView(this, field.getName(), padding, textSize));
        }
    }
    table.addView(headers);
}
 
Example #29
Source File: TableLayout.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new table layout.
 *
 * @param context  view context
 */
TableLayout(Context context, int numColumns, int numRows) {
  layoutManager = new android.widget.TableLayout(context);
  this.numColumns = numColumns;
  this.numRows = numRows;
  handler = new Handler();

  for (int row = 0; row < numRows; row++) {
    TableRow tableRow = new TableRow(context);
    for (int col = 0; col < numColumns; col++) {
      tableRow.addView(newEmptyCellView(), col, newEmptyCellLayoutParams());
    }
    layoutManager.addView(tableRow, row, new android.widget.TableLayout.LayoutParams());
  }
}
 
Example #30
Source File: RadioSectionFragment.java    From satstat with GNU General Public License v3.0 5 votes vote down vote up
protected void showCellLte(CellTowerLte cellTower) {
	TableRow row = (TableRow) mainActivity.getLayoutInflater().inflate(R.layout.ril_list_item, null);
	TextView type = (TextView) row.findViewById(R.id.type);
	TextView mcc = (TextView) row.findViewById(R.id.mcc);
	TextView mnc = (TextView) row.findViewById(R.id.mnc);
	TextView area = (TextView) row.findViewById(R.id.area);
	TextView cell = (TextView) row.findViewById(R.id.cell);
	TextView cell2 = (TextView) row.findViewById(R.id.cell2);
	TextView unit = (TextView) row.findViewById(R.id.unit);
	TextView dbm = (TextView) row.findViewById(R.id.dbm);

	type.setTextColor(rilLteCells.getContext().getResources().getColor(getColorFromGeneration(cellTower.getGeneration())));
	type.setText(rilLteCells.getContext().getResources().getString(R.string.smallDot));

	mcc.setText(formatCellData(rilLteCells.getContext(), "%03d", cellTower.getMcc()));

	mnc.setText(formatCellData(rilLteCells.getContext(), "%02d", cellTower.getMnc()));

	area.setText(formatCellData(rilLteCells.getContext(), null, cellTower.getTac()));

	int eNodeBId = cellTower.getCi() / 0x100;
	int sectorId = cellTower.getCi() % 0x100;
	if ((mainActivity.prefCid) && (cellTower.getCi() != CellTower.UNKNOWN)) {
		cell.setText(String.format("%d-%d", eNodeBId, sectorId));
		cell2.setText(formatCellData(rilLteCells.getContext(), null, cellTower.getCi()));
	} else {
		cell.setText(formatCellData(rilLteCells.getContext(), null, cellTower.getCi()));
		cell2.setText(String.format("%d-%d", eNodeBId, sectorId));
	}
	cell2.setVisibility(mainActivity.prefCid2 ? View.VISIBLE : View.GONE);

	unit.setText(formatCellData(rilLteCells.getContext(), null, cellTower.getPci()));

	dbm.setText(formatCellDbm(rilLteCells.getContext(), null, cellTower.getDbm()));

	rilLteCells.addView(row,new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
}