List of usage examples for android.widget TableRow setBackgroundColor
@RemotableViewMethod public void setBackgroundColor(@ColorInt int color)
From source file:com.adamkruger.myipaddressinfo.NetworkInfoFragment.java
private void addTableRow(Row row) { if (row.mLabel.length() > 0 || row.mValue.length() > 0) { int horizontalPadding = (int) (getResources().getDisplayMetrics().density * getResources().getDimension(R.dimen.label_value_padding) + 0.5f); TextView labelView = makeTextView(row.mLabel, getResources().getColor(R.color.dark_text_color), horizontalPadding);//from w w w.j a v a 2 s. c o m labelView.setGravity(Gravity.RIGHT); TextView valueView = makeTextView(row.mValue, getResources().getColor(R.color.dark_text_color), horizontalPadding); TableRow tableRow = makeTableRow(labelView, valueView); int verticalPadding = (int) (getResources().getDisplayMetrics().density * getResources().getDimension(R.dimen.network_info_vertical_padding) + 0.5f); tableRow.setPadding(0, verticalPadding, 0, verticalPadding); tableRow.setBackgroundColor(getResources().getColor(R.color.background_color_white)); tableRow.setGravity(Gravity.CENTER_HORIZONTAL); mNetworkInfoTableLayout.addView(tableRow); } }
From source file:com.woofer.activity.personHomeActivity.java
public void showTable() { TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT); layoutParams.gravity = Gravity.LEFT; layoutParams.leftMargin = 30;//from w w w . j ava 2 s .c o m layoutParams.bottomMargin = 10; layoutParams.topMargin = 10; for (int i = 0; i < 30; i++) { TableRow tableRow = new TableRow(this); TextView textView7 = new TextView(this); textView7.setText("" + i); textView7.setTextSize(18); textView7.setTextColor(Color.rgb(0, 0, 0)); textView7.setPadding(15, 0, 15, 0); tableRow.addView(textView7, layoutParams); tableRow.setBackgroundColor(Color.WHITE); final int n = i; tableRow.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(personHomeActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show(); } }); mMainLayout.addView(tableRow); TableRow tableRow1 = new TableRow(this); TextView textView1 = new TextView(this); textView1.setText("Test pull down scrollvsfadasdsadsasadsadsadsadsadasdsadasdasdsadsaddasdiew " + i); textView1.setTextSize(16); textView1.setPadding(15, 0, 15, 15); tableRow1.addView(textView1, layoutParams); tableRow1.setBackgroundColor(Color.WHITE); tableRow.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(personHomeActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show(); } }); mMainLayout.addView(tableRow1); // TableRow tableRow2 = new TableRow(this); // //tableRow2.addView(textView2, layoutParams); // ImageView imageView = new ImageView(this); // imageView.setImageResource(R.drawable.icon_reply_t); // imageView.setScaleX((float) a); // imageView.setScaleY((float) a); // imageView.setPadding(0, 0, 0, 0); // // ImageView imageView1 = new ImageView(this); // imageView1.setImageResource(R.drawable.icon_thumb_t); // imageView1.setScaleX((float) a); // imageView1.setScaleY((float) a); // imageView1.setPadding(0, 0, 0, 0); // // // //tableRow2.addView(imageView); // tableRow2.addView(imageView1); // mMainLayout.addView(tableRow2); TableLayout mytable = (TableLayout) findViewById(R.id.degital_textTL); int numberOfRow = 1; int numberOfColumn = 12; int cellDimension = 24; int cellPadding = 200; for (int row = 0; row < numberOfRow; row++) { tableRow = new TableRow(this); //tableRow.setLayoutParams(new TableLayout.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,TableRow.LayoutParams.MATCH_PARENT)); tableRow.setLayoutParams(new TableLayout.LayoutParams( (cellDimension + 2 * cellPadding) * numberOfColumn, cellDimension + 2 * cellPadding)); for (int column = 0; column < numberOfColumn; column++) { if (column % 3 == 0) { TextView textView = new TextView(this); textView.setTextSize(20); textView.setText(" "); tableRow.addView(textView); } if (column % 3 == 1) { if (column == 1) { ImageView imageView = new ImageView(this); imageView.setScaleX((float) 0.5); imageView.setScaleY((float) 0.5); imageView.setImageResource(R.drawable.icon_eye_t); tableRow.addView(imageView); } if (column == 4) { ImageView imageView = new ImageView(this); imageView.setScaleX((float) 0.5); imageView.setScaleY((float) 0.5); imageView.setImageResource(R.drawable.icon_thumb_t); tableRow.addView(imageView); } if (column == 7) { ImageView imageView = new ImageView(this); imageView.setScaleX((float) 0.5); imageView.setScaleY((float) 0.5); imageView.setImageResource(R.drawable.icon_reply_t); tableRow.addView(imageView); } if (column == 10) { ImageView imageView = new ImageView(this); imageView.setScaleX((float) 0.5); imageView.setScaleY((float) 0.5); imageView.setImageResource(R.drawable.icon_pencil_t); tableRow.addView(imageView); } } if (column % 3 == 2) { if (column == 2) { TextView textView = new TextView(this); textView.setText("8"); tableRow.addView(textView); } if (column == 5) { TextView textView = new TextView(this); textView.setText("8"); tableRow.addView(textView); } if (column == 8) { TextView textView = new TextView(this); textView.setText("8"); tableRow.addView(textView); } if (column == 11) { TextView textView = new TextView(this); textView.setText("8"); tableRow.addView(textView); } } } mytable.addView(tableRow, new TableLayout.LayoutParams( (cellDimension + 2 * cellPadding) * numberOfColumn, cellDimension + 2 * cellPadding)); //mytable.addView(tableRow,new TableLayout.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,TableRow.LayoutParams.MATCH_PARENT)); } } }
From source file:com.landenlabs.all_devtool.TextFragment.java
private void fillLayout() { m_tableLayout.removeAllViews();/* w w w . jav a2s. c o m*/ m_textInfoList.clear(); int minSP = 8; int maxSP = 20; int stepSP = 2; int[] colors = new int[] { 0xffe0e0e0, 0xffffe0e0, 0xffe0ffe0, 0xffe0e0ff }; TableLayout.LayoutParams tableLP = new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT); TableRow.LayoutParams rowLP = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.MATCH_PARENT); TextView textView; TableRow tableRow; int textColor = 0xff000000; for (int tfIdx = 0; tfIdx < TextInfo.getCount(); tfIdx++) { Typeface typeface = TextInfo.getTypeface(tfIdx); String typefaceStr = TextInfo.getTypefaceStr(tfIdx); textView = new TextView(m_context); textView.setBackgroundColor(Utils.blend(colors[tfIdx], 0x20000000)); textView.setText(typefaceStr); textView.setGravity(Gravity.CENTER); textView.setTextColor(textColor); m_tableLayout.addView(textView, tableLP); for (int sizeSP = minSP; sizeSP <= maxSP; sizeSP += stepSP) { tableRow = new TableRow(m_context); tableRow.setBackgroundColor(colors[tfIdx]); tableRow.setTag(Integer.valueOf(m_textInfoList.size())); m_textInfoList.add(new TextInfo(sizeSP, tfIdx)); tableRow.setClickable(true); tableRow.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { int idx = (Integer) v.getTag(); showTextDialog(m_textInfoList, idx); } }); textView = new TextView(m_context); textView.setText(String.valueOf(sizeSP) + "sp "); textView.setBackgroundColor(0x20000000); textView.setPadding(8, 0, 8, 0); textView.setGravity(Gravity.CENTER); textView.setTextColor(textColor); tableRow.addView(textView, rowLP); textView = new TextView(m_context); textView.setText("Normal"); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, sizeSP); textView.setTypeface(typeface, Typeface.NORMAL); textView.setGravity(Gravity.CENTER); textView.setTextColor(textColor); tableRow.addView(textView, rowLP); textView = new TextView(m_context); textView.setText("Bold"); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, sizeSP); textView.setTypeface(typeface, Typeface.BOLD); textView.setPadding(8, 0, 8, 0); textView.setGravity(Gravity.CENTER); textView.setTextColor(textColor); tableRow.addView(textView, rowLP); textView = new TextView(m_context); textView.setText("Italic"); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, sizeSP); textView.setTypeface(typeface, Typeface.ITALIC); textView.setGravity(Gravity.CENTER); textView.setTextColor(textColor); tableRow.addView(textView, rowLP); m_tableLayout.addView(tableRow, tableLP); } } }
From source file:com.bonsai.btcreceive.TransactionsFragment.java
private void addTransactionRow(String hash, TableLayout table, String datestr, String timestr, String confstr, String btcstr, String btcbalstr, String fiatstr, String fiatbalstr, boolean tintrow) { TableRow row = (TableRow) LayoutInflater.from(getActivity()).inflate(R.layout.transaction_table_row, table, false);/*from w w w .ja v a 2 s . c om*/ row.setTag(hash); row.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { // Dispatch to the transaction viewer. String hash = (String) view.getTag(); Intent intent = new Intent(getActivity(), ViewTransactionActivity.class); intent.putExtra("hash", hash); startActivity(intent); } }); { TextView tv = (TextView) row.findViewById(R.id.row_date); tv.setText(datestr); } { TextView tv = (TextView) row.findViewById(R.id.row_time); tv.setText(timestr); } { TextView tv = (TextView) row.findViewById(R.id.row_confidence); tv.setText(confstr); } { TextView tv = (TextView) row.findViewById(R.id.row_btc_balance); tv.setText(btcbalstr); } { TextView tv = (TextView) row.findViewById(R.id.row_btc); tv.setText(btcstr); } { TextView tv = (TextView) row.findViewById(R.id.row_fiat_balance); tv.setText(fiatbalstr); } { TextView tv = (TextView) row.findViewById(R.id.row_fiat); tv.setText(fiatstr); } if (tintrow) row.setBackgroundColor(Color.parseColor("#ccffcc")); table.addView(row); }
From source file:com.nest5.businessClient.Initialactivity.java
private void makeTable(String name) { table.removeAllViews();/*from ww w .j av a 2s.c o m*/ Iterator<Entry<Registrable, Integer>> it = currentOrder.entrySet().iterator(); int i = 0; while (it.hasNext()) { LinkedHashMap.Entry<Registrable, Integer> pairs = (LinkedHashMap.Entry<Registrable, Integer>) it.next(); // System.out.println(pairs.getKey() + " = " + pairs.getValue()); // it.remove(); // avoids a ConcurrentModificationException TableRow tr = (TableRow) getLayoutInflater().inflate(R.layout.table_row, null); TextView tItem = (TextView) tr.findViewById(R.id.cell_item); TextView tQty = (TextView) tr.findViewById(R.id.cell_qty); TextView tPrice = (TextView) tr.findViewById(R.id.cell_price); ImageButton rmvBtn = (ImageButton) tr.findViewById(R.id.cell_remove_button); tItem.setText(pairs.getKey().name); tQty.setText(String.valueOf(pairs.getValue())); tPrice.setText(String.valueOf(pairs.getKey().price)); if (name == pairs.getKey().name) { tr.setBackgroundColor(Color.parseColor("#55222222")); } rmvBtn.setOnClickListener(removeClickListener); rmvBtn.setId(i); table.addView(tr); // Draw separator TextView tv = new TextView(mContext); tv.setBackgroundColor(Color.parseColor("#80808080")); tv.setHeight(2); table.addView(tv); inTableRegistrable.add(i, pairs.getKey()); i++; } }
From source file:com.nest5.businessClient.Initialactivity.java
private void makeDailyTable(int TABLE_TYPE) { dailyTable.removeAllViews();/*from w w w .j a va2 s . c om*/ Double total = 0.0; DecimalFormat dec = new DecimalFormat("$###,###,###"); TextView tv = new TextView(mContext); tv.setBackgroundColor(Color.parseColor("#80808080")); tv.setHeight(2); TableRow tr1 = (TableRow) getLayoutInflater().inflate(R.layout.daily_table_row, null); TextView tDate1 = (TextView) tr1.findViewById(R.id.cell_date); TextView tItem1 = (TextView) tr1.findViewById(R.id.cell_item); TextView tAccount1 = (TextView) tr1.findViewById(R.id.cell_account); TextView tVal1 = (TextView) tr1.findViewById(R.id.cell_value); TextView tTot1 = (TextView) tr1.findViewById(R.id.cell_total); tDate1.setText("FECHA"); tAccount1.setText("CUENTA"); tItem1.setText("ITEM"); tVal1.setText("VALOR"); tTot1.setText("TOTAL"); tr1.setBackgroundColor(Color.CYAN); dailyTable.addView(tr1); dailyTable.addView(tv); //actualizar sales de hoy Calendar today = Calendar.getInstance(); Calendar tomorrow = Calendar.getInstance(); today.set(Calendar.HOUR, 0); today.set(Calendar.HOUR_OF_DAY, 0); today.set(Calendar.MINUTE, 0); today.set(Calendar.SECOND, 0); today.set(Calendar.MILLISECOND, 0); tomorrow.roll(Calendar.DATE, 1); tomorrow.set(Calendar.HOUR, 0); tomorrow.set(Calendar.HOUR_OF_DAY, 0); tomorrow.set(Calendar.MINUTE, 0); tomorrow.set(Calendar.SECOND, 0); tomorrow.set(Calendar.MILLISECOND, 0); init = today.getTimeInMillis(); end = tomorrow.getTimeInMillis(); Log.d("GUARDANDOVENTA", today.toString()); Log.d("GUARDANDOVENTA", tomorrow.toString()); Calendar now = Calendar.getInstance(); now.setTimeInMillis(System.currentTimeMillis()); Log.d(TAG, now.toString()); Log.d(TAG, "Diferencia entre tiempos: " + String.valueOf(end - init)); salesFromToday = saleDataSource.getAllSalesWithin(init, end); List<Sale> usingSales = salesFromToday; switch (TABLE_TYPE) { case TABLE_TYPE_TODAY: usingSales = salesFromToday; break; case TABLE_TYPE_ALL: usingSales = saleList; break; } for (Sale currentSale : usingSales) { double totalLocal = 0.0; LinkedHashMap<Combo, Double> combos = currentSale.getCombos(); LinkedHashMap<Product, Double> products = currentSale.getProducts(); LinkedHashMap<Ingredient, Double> ingredients = currentSale.getIngredients(); Log.w("DAYILETABLES", " " + combos.size() + " " + products.size() + " " + ingredients.size()); Iterator<Entry<Combo, Double>> it = combos.entrySet().iterator(); Calendar date = Calendar.getInstance(); date.setTimeInMillis(currentSale.getDate()); String fecha = date.get(Calendar.MONTH) + "/" + date.get(Calendar.DAY_OF_MONTH) + "/" + date.get(Calendar.YEAR) + "\n" + date.get(Calendar.HOUR_OF_DAY) + ":" + date.get(Calendar.MINUTE) + ":" + date.get(Calendar.SECOND); String account = currentSale.getPaymentMethod(); while (it.hasNext()) { TableRow tr = (TableRow) getLayoutInflater().inflate(R.layout.daily_table_row, null); TextView tDate = (TextView) tr.findViewById(R.id.cell_date); TextView tItem = (TextView) tr.findViewById(R.id.cell_item); TextView tAccount = (TextView) tr.findViewById(R.id.cell_account); TextView tVal = (TextView) tr.findViewById(R.id.cell_value); TextView tTot = (TextView) tr.findViewById(R.id.cell_total); Map.Entry<Combo, Double> pair = (Map.Entry<Combo, Double>) it.next(); Double value = pair.getValue() * pair.getKey().getPrice(); tDate.setText(fecha); tAccount.setText(account); tItem.setText(pair.getKey().getName() + " en Combo"); tVal.setText(dec.format(value)); tTot.setText("----"); total += value; totalLocal += value; dailyTable.addView(tr); // Log.d("INGREDIENTES","INGREDIENTE: "+ingrediente.getKey().getName()+" "+ingrediente.getValue()); } Iterator<Entry<Product, Double>> it2 = products.entrySet().iterator(); while (it2.hasNext()) { Map.Entry<Product, Double> pair = (Map.Entry<Product, Double>) it2.next(); TableRow tr = (TableRow) getLayoutInflater().inflate(R.layout.daily_table_row, null); TextView tDate = (TextView) tr.findViewById(R.id.cell_date); TextView tItem = (TextView) tr.findViewById(R.id.cell_item); TextView tAccount = (TextView) tr.findViewById(R.id.cell_account); TextView tVal = (TextView) tr.findViewById(R.id.cell_value); TextView tTot = (TextView) tr.findViewById(R.id.cell_total); Double value = pair.getValue() * pair.getKey().getPrice(); tDate.setText(fecha); tAccount.setText(account); tItem.setText(pair.getKey().getName()); tVal.setText(dec.format(value)); tTot.setText("----"); total += value; totalLocal += value; dailyTable.addView(tr); // Log.d("INGREDIENTES","INGREDIENTE: "+ingrediente.getKey().getName()+" "+ingrediente.getValue()); } Iterator<Entry<Ingredient, Double>> it3 = ingredients.entrySet().iterator(); while (it3.hasNext()) { Map.Entry<Ingredient, Double> pair = (Map.Entry<Ingredient, Double>) it3.next(); TableRow tr = (TableRow) getLayoutInflater().inflate(R.layout.daily_table_row, null); TextView tDate = (TextView) tr.findViewById(R.id.cell_date); TextView tItem = (TextView) tr.findViewById(R.id.cell_item); TextView tAccount = (TextView) tr.findViewById(R.id.cell_account); TextView tVal = (TextView) tr.findViewById(R.id.cell_value); TextView tTot = (TextView) tr.findViewById(R.id.cell_total); Double value = pair.getValue() * pair.getKey().getPrice(); tDate.setText(fecha); tAccount.setText(account); tItem.setText(pair.getKey().getName()); tVal.setText(dec.format(value)); tTot.setText("----"); total += value; totalLocal += value; dailyTable.addView(tr); // Log.d("INGREDIENTES","INGREDIENTE: "+ingrediente.getKey().getName()+" "+ingrediente.getValue()); } TableRow tr = (TableRow) getLayoutInflater().inflate(R.layout.daily_table_row, null); TextView tDate = (TextView) tr.findViewById(R.id.cell_date); TextView tItem = (TextView) tr.findViewById(R.id.cell_item); TextView tAccount = (TextView) tr.findViewById(R.id.cell_account); TextView tVal = (TextView) tr.findViewById(R.id.cell_value); TextView tTot = (TextView) tr.findViewById(R.id.cell_total); tDate.setText(fecha); tAccount.setText("-------"); tItem.setText("Ingreso por Ventas"); tVal.setText("----"); tTot.setText(dec.format(totalLocal)); tr.setBackgroundColor(Color.LTGRAY); dailyTable.addView(tr); TableRow tr2 = (TableRow) getLayoutInflater().inflate(R.layout.daily_table_row, null); TextView tDate2 = (TextView) tr2.findViewById(R.id.cell_date); TextView tItem2 = (TextView) tr2.findViewById(R.id.cell_item); TextView tAccount2 = (TextView) tr2.findViewById(R.id.cell_account); TextView tVal2 = (TextView) tr2.findViewById(R.id.cell_value); TextView tTot2 = (TextView) tr2.findViewById(R.id.cell_total); tDate2.setText(fecha); tAccount2.setText("-------"); tItem2.setText("Acumulado por Ventas"); tVal2.setText("----"); tTot2.setText(dec.format(total)); tr2.setBackgroundColor(Color.GRAY); dailyTable.addView(tr2); } }
From source file:com.nest5.businessClient.Initialactivity.java
private void makeInventoryTable(List<Ingredient> ingredients) { inventoryTable.removeAllViews();// ww w .j av a 2 s . co m Double total = 0.0; DecimalFormat dec = new DecimalFormat("$###,###,###"); TextView tv = new TextView(mContext); tv.setBackgroundColor(Color.parseColor("#80808080")); tv.setHeight(2); TableRow tr1 = (TableRow) getLayoutInflater().inflate(R.layout.inventory_table_row, null); TextView tDate1 = (TextView) tr1.findViewById(R.id.cell_date); TextView tItem1 = (TextView) tr1.findViewById(R.id.cell_type); TextView tAccount1 = (TextView) tr1.findViewById(R.id.cell_qty); TextView tVal1 = (TextView) tr1.findViewById(R.id.cell_unit_value); TextView tTot1 = (TextView) tr1.findViewById(R.id.cell_total_value); TextView tTotTot1 = (TextView) tr1.findViewById(R.id.cell_total_total); tDate1.setText("FECHA"); tAccount1.setText("CANTIDAD"); tItem1.setText("TIPO"); tVal1.setText("VALOR\nUNIDAD"); tTot1.setText("TOTAL\nITEM"); tTotTot1.setText("TOTAL"); tr1.setBackgroundColor(Color.CYAN); inventoryTable.addView(tr1); inventoryTable.addView(tv); for (Ingredient current : ingredients) { Calendar date = Calendar.getInstance(); date.setTimeInMillis(current.getDate()); String fecha = date.get(Calendar.MONTH) + "/" + date.get(Calendar.DAY_OF_MONTH) + "/" + date.get(Calendar.YEAR) + "\n" + date.get(Calendar.HOUR_OF_DAY) + ":" + date.get(Calendar.MINUTE) + ":" + date.get(Calendar.SECOND); Double localVal = current.getQty() * current.getCostPerUnit(); total += localVal; TableRow tr = (TableRow) getLayoutInflater().inflate(R.layout.inventory_table_row, null); TextView tDate = (TextView) tr.findViewById(R.id.cell_date); TextView tType = (TextView) tr.findViewById(R.id.cell_type); TextView tQty = (TextView) tr.findViewById(R.id.cell_qty); TextView tVal = (TextView) tr.findViewById(R.id.cell_unit_value); TextView tTot = (TextView) tr.findViewById(R.id.cell_total_value); TextView tTotTot = (TextView) tr.findViewById(R.id.cell_total_total); tDate.setText(fecha); tType.setText("E"); tQty.setText(String.valueOf(current.getQty())); tVal.setText(dec.format(current.getCostPerUnit())); tTot.setText(dec.format(localVal)); tTotTot.setText(" ----- "); inventoryTable.addView(tr); } TableRow tr2 = (TableRow) getLayoutInflater().inflate(R.layout.inventory_table_row, null); TextView tDate2 = (TextView) tr2.findViewById(R.id.cell_date); TextView tType2 = (TextView) tr2.findViewById(R.id.cell_type); TextView tQty2 = (TextView) tr2.findViewById(R.id.cell_qty); TextView tVal2 = (TextView) tr2.findViewById(R.id.cell_unit_value); TextView tTot2 = (TextView) tr2.findViewById(R.id.cell_total_value); TextView tTotTot2 = (TextView) tr2.findViewById(R.id.cell_total_total); tDate2.setText("------"); tType2.setText("-----"); tQty2.setText("-----"); tVal2.setText("-----"); tTot2.setText("TOTAL GENERAL"); tTotTot2.setText(dec.format(total)); tr2.setBackgroundColor(Color.LTGRAY); inventoryTable.addView(tr2); }