Java Code Examples for android.widget.TableRow#addView()
The following examples show how to use
android.widget.TableRow#addView() .
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: DeviceInfoActivity.java From YalpStore with GNU General Public License v2.0 | 6 votes |
private void addRow(TableLayout parent, String key, String value) { TableRow.LayoutParams rowParams = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT); TextView textViewKey = new TextView(this); textViewKey.setText(key); textViewKey.setLayoutParams(rowParams); TextView textViewValue = new TextView(this); textViewValue.setText(value); textViewValue.setLayoutParams(rowParams); TableRow tableRow = new TableRow(this); tableRow.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT)); tableRow.addView(textViewKey); tableRow.addView(textViewValue); parent.addView(tableRow); }
Example 2
Source File: StretchViewActivity.java From BigApp_Discuz_Android with Apache License 2.0 | 6 votes |
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 3
Source File: BodyElementTableRow.java From RedReader with GNU General Public License v3.0 | 6 votes |
@Override public View generateView( @NonNull final AppCompatActivity activity, @Nullable final Integer textColor, @Nullable final Float textSize, final boolean showLinkButtons) { final TableRow result = new TableRow(activity); for(final BodyElement element : mElements) { final View view = element.generateView(activity, textColor, textSize, showLinkButtons); result.addView(view); final TableRow.LayoutParams layoutParams = (TableRow.LayoutParams)view.getLayoutParams(); layoutParams.width = ViewGroup.LayoutParams.WRAP_CONTENT; layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT; view.setLayoutParams(layoutParams); } return result; }
Example 4
Source File: StretchViewActivity.java From UltimateAndroid with Apache License 2.0 | 5 votes |
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 5
Source File: DisplayModelActivity.java From nosey with Apache License 2.0 | 5 votes |
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 6
Source File: ColorPickerPalette.java From ColorPicker with Apache License 2.0 | 5 votes |
/** * 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, boolean backwardsOrder) { if (backwardsOrder) { if (rowNumber % 2 == 0) { row.addView(swatch); } else { row.addView(swatch, 0); } } else { row.addView(swatch); } }
Example 7
Source File: ColorPickerPalette.java From Swiftnotes with Apache License 2.0 | 5 votes |
/** * 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 8
Source File: ColorPickerPalette.java From privacy-friendly-ludo with GNU General Public License v3.0 | 5 votes |
/** * 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 9
Source File: MainActivity.java From rpicheck with MIT License | 5 votes |
private View createDiskRow(DiskUsageBean disk) { final TableRow tempRow = new TableRow(this); tempRow.addView(createTextView(disk.getFileSystem())); tempRow.addView(createTextView(disk.getSize())); tempRow.addView(createTextView(disk.getAvailable())); tempRow.addView(createTextView(disk.getUsedPercent())); tempRow.addView(createTextView(disk.getMountedOn())); return tempRow; }
Example 10
Source File: EditCredentialsActivity.java From WiFiAfterConnect with Apache License 2.0 | 5 votes |
private void addField (HtmlInput field) { Log.d(Constants.TAG, "adding ["+field.getName() + "], type = [" + field.getType()+"]"); TextView labelView = new TextView(this); labelView.setText(field.getName()); int textSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, (float) 8, getResources().getDisplayMetrics()); labelView.setTextSize (textSize); EditText editView = new EditText(this); editView.setInputType(field.getAndroidInputType()); editView.setText (field.getValue()); editView.setTag(field.getName()); editView.setFocusable (true); edits.add(editView); editView.setOnEditorActionListener(new EditText.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { onSaveClick(v); } return false; } }); TableRow row = new TableRow (this); fieldsTable.addView (row, new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT,TableLayout.LayoutParams.WRAP_CONTENT)); TableRow.LayoutParams labelLayout = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,TableRow.LayoutParams.WRAP_CONTENT); int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) 5, getResources().getDisplayMetrics()); labelLayout.setMargins(margin, margin, margin, margin); row.addView(labelView, labelLayout); TableRow.LayoutParams editLayout = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,TableRow.LayoutParams.WRAP_CONTENT); row.addView(editView, editLayout); }
Example 11
Source File: PulldownViewActivity.java From PullScrollView with Apache License 2.0 | 5 votes |
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 12
Source File: MainActivity.java From video-tutorial-code with BSD 2-Clause "Simplified" License | 5 votes |
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: template_automatic_ll.java From KickAssSlidingMenu with Apache License 2.0 | 5 votes |
protected void phoneTileRender() { int sizeNow, index = 0, halfSizeOnHold = 0; boolean cell_open = false; Iterator<bind> loop = list_configuration.iterator(); TableRow temp_row = newTempHolder(); while (loop.hasNext()) { bind dlp = loop.next(); sizeNow = dlp.size; if (sizeNow == bind.FULL) { if (cell_open) { //close half ll.addView(temp_row, new TableLayout.LayoutParams(screen_size.x, row_height)); cell_open = false; halfSizeOnHold = 0; } ll.addView(newRelativeLayout(dlp, sizeNow)); } else if (sizeNow == bind.HALF) { if (!cell_open) { temp_row = newTempHolder(); cell_open = true; } halfSizeOnHold++; //adding view to layout temp_row.addView(newRelativeLayout(dlp, sizeNow)); } if (index == list_configuration.size() - 1 && cell_open || cell_open && halfSizeOnHold >= 2) { ll.addView(temp_row, new TableLayout.LayoutParams(screen_size.x, row_height)); cell_open = false; halfSizeOnHold = 0; } index++; } }
Example 14
Source File: TimetableView.java From TimetableView with Apache License 2.0 | 5 votes |
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); } } }
Example 15
Source File: ColorPickerPalette.java From Tweetin with Apache License 2.0 | 5 votes |
private void addSwatchToRow(TableRow tableRow, View view, int line) { if (line % 2 == 0) { tableRow.addView(view); return; } tableRow.addView(view, 0); }
Example 16
Source File: ColorPickerPalette.java From KAM with GNU General Public License v3.0 | 5 votes |
/** * 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 void addSwatchToRow(TableRow row, View swatch, int rowNumber) { if (rowNumber % 2 == 0) { row.addView(swatch); } else { row.addView(swatch, 0); } }
Example 17
Source File: MeasurementView.java From openScale with GNU General Public License v3.0 | 4 votes |
private void initView(Context context) { measurementRow = new TableRow(context); iconView = new ImageView(context); iconViewBackground = new GradientDrawable(); nameView = new TextView(context); valueView = new TextView(context); editModeView = new ImageView(context); indicatorView = new ImageView(context); evaluatorRow = new TableRow(context); evaluatorView = new LinearGaugeView(context); incDecLayout = new LinearLayout(context); measurementRow.setLayoutParams(new TableRow.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT, 1.0f)); measurementRow.setGravity(Gravity.CENTER); measurementRow.addView(iconView); measurementRow.addView(nameView); measurementRow.addView(valueView); measurementRow.addView(incDecLayout); measurementRow.addView(editModeView); measurementRow.addView(indicatorView); addView(measurementRow); addView(evaluatorRow); iconViewBackground.setColor(ColorUtil.COLOR_GRAY); iconViewBackground.setShape(GradientDrawable.OVAL); iconViewBackground.setGradientRadius(iconView.getWidth()); iconView.setImageResource(iconId); iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); iconView.setPadding(25,25,25,25); iconView.setColorFilter(ColorUtil.COLOR_BLACK); iconView.setBackground(iconViewBackground); TableRow.LayoutParams iconLayout = new TableRow.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); iconLayout.setMargins(10, 5, 10, 5); iconView.setLayoutParams(iconLayout); nameView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15); nameView.setLines(2); nameView.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 0.55f)); valueView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15); valueView.setGravity(Gravity.RIGHT | Gravity.CENTER); valueView.setPadding(0,0,20,0); valueView.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 0.29f)); incDecLayout.setOrientation(VERTICAL); incDecLayout.setVisibility(View.GONE); incDecLayout.setPadding(0,0,0,0); incDecLayout.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.MATCH_PARENT, 0.05f)); editModeView.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_editable)); editModeView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); editModeView.setVisibility(View.GONE); editModeView.setColorFilter(getForegroundColor()); indicatorView.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.MATCH_PARENT, 0.01f)); indicatorView.setBackgroundColor(Color.GRAY); evaluatorRow.setLayoutParams(new TableRow.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT, 1.0f)); evaluatorRow.addView(new Space(context)); evaluatorRow.addView(evaluatorView); Space spaceAfterEvaluatorView = new Space(context); evaluatorRow.addView(spaceAfterEvaluatorView); evaluatorRow.setVisibility(View.GONE); evaluatorView.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 0.99f)); spaceAfterEvaluatorView.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 0.01f)); setOnClickListener(new onClickListenerEvaluation()); }
Example 18
Source File: ProviderTable.java From ssj with GNU General Public License v3.0 | 4 votes |
/** * @param activity Activity * @param mainObject Object * @param dividerTop boolean * @return TableRow */ public static TableRow createStreamTable(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 = PipelineBuilder.getInstance().getPossibleStreamConnections(mainObject); // 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[] providers = PipelineBuilder.getInstance().getStreamConnections(mainObject); if (providers != null) { for (Object provider : providers) { if (objects[i].equals(provider)) { 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().addStreamConnection(mainObject, (Provider) o); } else { PipelineBuilder.getInstance().removeStreamConnection(mainObject, (Provider) o); } } }); linearLayout.addView(checkBox); } } else { return null; } tableRow.addView(linearLayout); return tableRow; }
Example 19
Source File: IPSettingActivity.java From faceswap with Apache License 2.0 | 4 votes |
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 20
Source File: ColorPickerPalette.java From Augendiagnose with GNU General Public License v2.0 | 2 votes |
/** * Appends a swatch to the end of the row. * * @param row The row. * @param swatch The swatch to be added. */ private static void addSwatchToRow(@NonNull final TableRow row, final View swatch) { row.addView(swatch); }