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

The following examples show how to use android.widget.TableRow#setLayoutParams() . 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: 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 2
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 3
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 4
Source File: NineGridView.java    From webrtc_android with MIT License 5 votes vote down vote up
private void initThis(Context context, AttributeSet attrs) {
    this.context = context;
    if (this.getTag() != null) {
        String atb = (String) this.getTag();
        int ix = atb.indexOf(',');
        if (ix > 0) {
            rowNum = Integer.parseInt(atb.substring(0, ix));
            colNum = Integer.parseInt(atb.substring(ix + 1, atb.length()));
        }
    }
    if (rowNum <= 0)
        rowNum = 3;
    if (colNum <= 0)
        colNum = 3;

    if (this.isInEditMode()) {
        this.removeAllViews();
        for (int y = 0; y < rowNum; ++y) {
            TableRow row = new TableRow(context);
            row.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT, 1.0f));
            for (int x = 0; x < colNum; ++x) {
                View button = new Button(context);
                row.addView(button, new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1.0f));
            }
            this.addView(row);
        }
    }
}
 
Example 5
Source File: ColorPickerPalette.java    From cathode with Apache License 2.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 6
Source File: ColorPickerPalette.java    From Swiftnotes with Apache License 2.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 7
Source File: ColorPickerPalette.java    From KAM 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 8
Source File: ColorPickerPalette.java    From ColorPicker with Apache License 2.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 9
Source File: ColorPickerPalette.java    From Augendiagnose with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Helper method to create a row of the table of colors.
 *
 * @return The row.
 */
@NonNull
private TableRow createTableRow() {
	TableRow row = new TableRow(getContext());
	ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
			ViewGroup.LayoutParams.WRAP_CONTENT);
	row.setLayoutParams(params);
	return row;
}
 
Example 10
Source File: OptionTable.java    From ssj with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @param activity   Activity
 * @param options    Option[]
 * @param owner Object
 * @return TableRow
 */
public static TableRow createTable(Activity activity, Option[] options, Object owner)
{
	TableRow tableRow = new TableRow(activity);
	tableRow.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.MATCH_PARENT));
	//
	LinearLayout linearLayout = new LinearLayout(activity);
	linearLayout.setOrientation(LinearLayout.VERTICAL);
	if (owner != null && (owner instanceof Transformer || owner instanceof Consumer))
	{
		//add divider
		linearLayout.addView(Util.addDivider(activity));
	}
	TextView textViewName = new TextView(activity);
	textViewName.setText(R.string.str_options);
	textViewName.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START);
	textViewName.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
	linearLayout.addView(textViewName);
	//
	LinearLayout linearLayoutOptions = new LinearLayout(activity);
	linearLayoutOptions.setBackgroundColor(activity.getResources().getColor(R.color.colorListBorder));
	linearLayoutOptions.setOrientation(LinearLayout.VERTICAL);
	//options
	for (int i = 0; i < options.length; i++)
	{
		if (options[i].isAssignableByString())
		{
			linearLayoutOptions.addView(addOption(activity, options[i], owner));
		}
	}
	linearLayout.addView(linearLayoutOptions);
	tableRow.addView(linearLayout);
	return tableRow;
}
 
Example 11
Source File: ValueBlocksToInt.java    From MifareClassicTool with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Add a row with position information to the layout table.
 * This row shows the user where the value block is located (sector, block).
 * @param value The position information (e.g. "Sector: 1, Block: 2").
 */
private void addPosInfoRow(String value) {
    TextView header = new TextView(this);
    header.setText(Common.colorString(value,
            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));
}
 
Example 12
Source File: MainActivity.java    From video-tutorial-code with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void populateButtons() {
   	TableLayout table = (TableLayout) findViewById(R.id.tableForButtons);
   	
   	for (int row = 0; row < NUM_ROWS; row++) {
   		TableRow tableRow = new TableRow(this);
   		tableRow.setLayoutParams(new TableLayout.LayoutParams(
   				TableLayout.LayoutParams.MATCH_PARENT,
   				TableLayout.LayoutParams.MATCH_PARENT,
   				1.0f));
   		table.addView(tableRow);
   		
   		for (int col = 0; col < NUM_COLS; col++){ 
   			final int FINAL_COL = col;
   			final int FINAL_ROW = row;
   			
   			Button button = new Button(this);
   			button.setLayoutParams(new TableRow.LayoutParams(
   					TableRow.LayoutParams.MATCH_PARENT,
   					TableRow.LayoutParams.MATCH_PARENT,
   					1.0f));
   			
   			button.setText("" + col + "," + row);
   			
   			// Make text not clip on small buttons
   			button.setPadding(0, 0, 0, 0);
   			
   			button.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {
					gridButtonClicked(FINAL_COL, FINAL_ROW);
				}
			});
   			
   			tableRow.addView(button);
   			buttons[row][col] = button;
   		}
   	}
}
 
Example 13
Source File: AdoptDialogBuilder.java    From Hauk with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a View that is rendered in the dialog window.
 *
 * @param ctx Android application context.
 * @return A View instance to render on the dialog.
 */
@Override
public final View createView(Context ctx) {
    // TODO: Inflate this instead
    // Ensure input boxes fill the entire width of the dialog.
    TableRow.LayoutParams trParams = new TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT);
    trParams.weight = 1.0F;

    TableLayout layout = new TableLayout(ctx);
    TableRow shareRow = new TableRow(ctx);
    shareRow.setLayoutParams(trParams);
    TableRow nickRow = new TableRow(ctx);
    nickRow.setLayoutParams(trParams);

    TextView textShare = new TextView(ctx);
    textShare.setText(R.string.label_share_url);

    TextView textNick = new TextView(ctx);
    textNick.setText(R.string.label_nickname);

    this.dialogTxtShare = new EditText(ctx);
    this.dialogTxtShare.setInputType(InputType.TYPE_CLASS_TEXT);
    this.dialogTxtShare.setLayoutParams(trParams);
    this.dialogTxtShare.addTextChangedListener(new LinkIDMatchReplacementListener(this.dialogTxtShare));

    this.dialogTxtNick = new EditText(ctx);
    this.dialogTxtNick.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PERSON_NAME);
    this.dialogTxtNick.setLayoutParams(trParams);

    shareRow.addView(textShare);
    shareRow.addView(this.dialogTxtShare);
    nickRow.addView(textNick);
    nickRow.addView(this.dialogTxtNick);

    layout.addView(shareRow);
    layout.addView(nickRow);

    return layout;
}
 
Example 14
Source File: ResultMatrixLayout.java    From microMathematics with GNU General Public License v3.0 4 votes vote down vote up
public void resize(int rows, int cols, int cellLayoutId)
{
    if (rowsNumber == rows && colsNumber == cols)
    {
        return;
    }
    rowsNumber = rows;
    colsNumber = cols;

    removeAllViews();
    fields.clear();

    final TableLayout.LayoutParams tableParams = new TableLayout.LayoutParams(
            TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT);

    final LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(
            Context.LAYOUT_INFLATER_SERVICE);

    for (int row = 0; row < rowsNumber; row++)
    {
        final TableRow tableRow = new TableRow(getContext());
        tableRow.setLayoutParams(tableParams); // TableLayout is the parent view
        addView(tableRow);

        for (int col = 0; col < colsNumber; col++)
        {
            inflater.inflate(cellLayoutId, tableRow);
        }

        if (tableRow.getChildCount() > 0)
        {
            tableRow.setBaselineAligned(true);
            tableRow.setBaselineAlignedChildIndex(0);
        }

        for (int col = 0; col < tableRow.getChildCount(); col++)
        {
            final CustomEditText c = (CustomEditText) tableRow.getChildAt(col);
            if (c != null)
            {
                c.setId(IdGenerator.generateId());
                c.setTag(new ElementTag(row, col, fields.size()));
                fields.add(c);
            }
        }
    }

    setPadding(0, 0, 0, 0);
    setBaselineAligned(true);
    setBaselineAlignedChildIndex(rowsNumber > 1 ? rowsNumber / 2 : 0);
}
 
Example 15
Source File: ProviderTable.java    From ssj with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @param activity   Activity
 * @param mainObject Object
 * @param dividerTop boolean
 * @return TableRow
 */
public static TableRow createModelTable(Activity activity, final Object mainObject, boolean dividerTop, int heading)
{
    TableRow tableRow = new TableRow(activity);
    tableRow.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT));
    LinearLayout linearLayout = new LinearLayout(activity);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    if (dividerTop)
    {
        //add divider
        linearLayout.addView(Util.addDivider(activity));
    }
    TextView textViewName = new TextView(activity);
    textViewName.setText(heading);
    textViewName.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START);
    textViewName.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22);
    linearLayout.addView(textViewName);

    //get possible providers
    final Object[] objects = (mainObject instanceof IModelHandler) ?
            PipelineBuilder.getInstance().getAll(PipelineBuilder.Type.Model) :
            PipelineBuilder.getInstance().getModelHandlers();

    if (objects.length > 0) {
        for (int i = 0; i < objects.length; i++) {
            CheckBox checkBox = new CheckBox(activity);
            checkBox.setText(objects[i].getClass().getSimpleName());
            checkBox.setTextSize(TypedValue.COMPLEX_UNIT_SP, 19);

            Object[] connections = PipelineBuilder.getInstance().getModelConnections(mainObject);
            if (connections != null) {
                for (Object conn : connections) {
                    if (objects[i].equals(conn)) {
                        checkBox.setChecked(true);
                        break;
                    }
                }
            }

            final int count = i;
            checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                final Object o = objects[count];

                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    if (isChecked) {
                        PipelineBuilder.getInstance().addModelConnection((Component) mainObject, (Component) o);
                    } else {
                        PipelineBuilder.getInstance().removeModelConnection((Component) mainObject, (Component) o);
                    }
                }
            });
            linearLayout.addView(checkBox);
        }
    } else
    {
        return null;
    }
    tableRow.addView(linearLayout);
    return tableRow;
}
 
Example 16
Source File: AccessConditionDecoder.java    From MifareClassicTool with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Add full access condition information of the 3 data blocks to the table.
 * @param acMatrix A matrix of access conditions bits as generated by
 * {@link Common#acBytesToACMatrix(byte[])}.
 * @param hasMoreThan4Blocks True for the last 8 sectors
 * of a MIFARE Classic 4K tag, False otherwise.
 */
private void addBlockAC(byte[][] acMatrix, boolean hasMoreThan4Blocks) {
    boolean isKeyBReadable = Common.isKeyBReadable(
            acMatrix[0][3], acMatrix[1][3], acMatrix[2][3]);

    for (int i = 0; i < 3; i++) {
        byte c1 = acMatrix[0][i];
        byte c2 = acMatrix[1][i];
        byte c3 = acMatrix[2][i];
        // Create row and header.
        TableRow tr = new TableRow(this);
        String blockHeader;
        if (hasMoreThan4Blocks) {
            blockHeader = getString(R.string.text_block)
                    + ": " + (i*4+i) + "-" + (i*4+4+i);
        } else {
            blockHeader = getString(R.string.text_block) + ": " + i;
        }
        tr.setLayoutParams(new LayoutParams(
                LayoutParams.MATCH_PARENT,
                LayoutParams.WRAP_CONTENT));
        // Create cells.
        TextView location = new TextView(this);
        location.setText(blockHeader);
        TextView read = new TextView(this);
        TextView write = new TextView(this);
        TextView incr = new TextView(this);
        TextView decr = new TextView(this);

        // Set cell texts to colored permissions.
        read.setText(getColoredPermissionText(c1, c2, c3,
                Operations.Read, false, isKeyBReadable));
        write.setText(getColoredPermissionText(c1, c2, c3,
                Operations.Write, false, isKeyBReadable));
        incr.setText(getColoredPermissionText(c1, c2, c3,
                Operations.Increment, false, isKeyBReadable));
        decr.setText(getColoredPermissionText(c1, c2, c3,
                Operations.DecTransRest, false, isKeyBReadable));

        // Add cells to row.
        tr.addView(location);
        tr.addView(read);
        tr.addView(write);
        tr.addView(incr);
        tr.addView(decr);
        // Add row to layout.
        mLayout.addView(tr, new LayoutParams(
                LayoutParams.MATCH_PARENT,
                LayoutParams.WRAP_CONTENT));
    }
}
 
Example 17
Source File: ColorPickerPalette.java    From Tweetin with Apache License 2.0 4 votes vote down vote up
private TableRow createTableRow() {
	TableRow localTableRow = new TableRow(getContext());
	localTableRow.setLayoutParams(new ViewGroup.LayoutParams(-2, -2));
	return localTableRow;
}
 
Example 18
Source File: IPSettingActivity.java    From faceswap with Apache License 2.0 4 votes vote down vote up
private void addPersonUIRow(final SharedPreferences mSharedPreferences, final int type,
                            final String name, String ip) {
    final TableLayout tb=tbs[type];

    //create a new table row
    final TableRow tr = new TableRow(this);
    TableRow.LayoutParams trTlp = new TableRow.LayoutParams(
            0,
            TableLayout.LayoutParams.WRAP_CONTENT
    );
    tr.setLayoutParams(trTlp);

    //create name view
    TextView nameView = new TextView(this);
    nameView.setText(name);
    nameView.setTextSize(20);
    TableRow.LayoutParams tlp1 = new TableRow.LayoutParams(
            TableLayout.LayoutParams.WRAP_CONTENT,
            TableLayout.LayoutParams.MATCH_PARENT
    );
    tlp1.column=0;
    nameView.setLayoutParams(tlp1);

    //create sub view
    TextView subView = new TextView(this);
    subView.setText(ip);
    subView.setTextSize(20);
    TableRow.LayoutParams tlp3 = new TableRow.LayoutParams(
            TableLayout.LayoutParams.WRAP_CONTENT,
            TableLayout.LayoutParams.MATCH_PARENT
    );
    tlp3.column=1;
    subView.setLayoutParams(tlp3);

    //create delete button
    ImageView deleteView = new ImageView(this);
    deleteView.setImageResource(R.drawable.ic_delete_black_24dp);
    TableRow.LayoutParams tlp4 = new TableRow.LayoutParams(
            TableLayout.LayoutParams.WRAP_CONTENT,
            TableLayout.LayoutParams.MATCH_PARENT
    );
    tlp4.column=2;
    deleteView.setLayoutParams(tlp4);
    deleteView.setOnClickListener(new ImageView.OnClickListener() {
        @Override
        public void onClick(View v) {
            //remove name from sharedPreferences
            String sharedPreferenceIpDictName=
                    getResources().getStringArray(R.array.shared_preference_ip_dict_names)[type];
            SharedPreferences.Editor editor = mSharedPreferences.edit();
            Set<String> existingNames =
                    new HashSet<String>(mSharedPreferences.getStringSet(sharedPreferenceIpDictName,
                            new HashSet<String>()));
            editor.remove(name);
            existingNames.remove(name);
            editor.putStringSet(sharedPreferenceIpDictName, existingNames);
            editor.commit();

            //remove current line from UI
            tb.removeView(tr);
        }
    });

    tr.addView(nameView);
    tr.addView(subView);
    tr.addView(deleteView);

    tb.addView(tr,
            new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT,
                    TableLayout.LayoutParams.WRAP_CONTENT));
}
 
Example 19
Source File: template_automatic_ll.java    From KickAssSlidingMenu with Apache License 2.0 4 votes vote down vote up
protected TableRow newTempHolderBy2() {
    TableRow linearLayout_temp = new TableRow(getActivity());
    linearLayout_temp.setLayoutParams(new TableRow.LayoutParams(screen_size.x, calculateRowHeightBy2()));
    return linearLayout_temp;
}
 
Example 20
Source File: template_automatic_ll.java    From KickAssSlidingMenu with Apache License 2.0 4 votes vote down vote up
protected TableRow newTempHolderBy2() {
    TableRow linearLayout_temp = new TableRow(getActivity());
    linearLayout_temp.setLayoutParams(new TableRow.LayoutParams(screen_size.x, calculateRowHeightBy2()));
    return linearLayout_temp;
}