public TableRow getTableTitleView() { TableRow rowTitle = new TableRow(getActivity()); rowTitle.setGravity(Gravity.CENTER_HORIZONTAL); TextView title = new TextView(getActivity()); title.setText(form.getTableName()); title.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); // title.setGravity(Gravity.CENTER); title.setTypeface(Typeface.SERIF, Typeface.BOLD); TableRow.LayoutParams params = new TableRow.LayoutParams(); params.span = columnNames.length; rowTitle.addView(title, params); return rowTitle; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.shopping_list_table); bReturn = (TextView) findViewById(R.id.bReturn); bReturn.setOnClickListener(this); TableLayout myTable = (TableLayout) findViewById(R.id.ListTable); List<Coupon> allCoupons = mDbHelper.getCouponsOfUser(Coupon.TABLE_LIST, Register.currentUsername); double total = 0.0; for (int i = 0; i < allCoupons.size(); i++) { TableRow items = new TableRow(this); TextView list_amount = new TextView(this); list_amount.setText(Integer.toString(allCoupons.get(i).getAmount())); list_amount.setTextColor(Color.BLACK); list_amount.setGravity(Gravity.CENTER_HORIZONTAL); list_amount.setTextSize(14); TextView list_item = new TextView(this); list_item.setText(allCoupons.get(i).getItemName()); list_item.setTypeface(Typeface.SERIF); list_item.setTextColor(Color.BLACK); list_item.setTextSize(14); TextView list_description = new TextView(this); list_description.setText(allCoupons.get(i).getDescription()); list_description.setTypeface(Typeface.SERIF); list_description.setTextColor(Color.BLACK); list_description.setTextSize(14); TextView list_price = new TextView(this); list_price.setText(Double.toString(allCoupons.get(i).getItemPrice())); list_price.setTypeface(Typeface.SERIF); list_price.setTextColor(Color.BLACK); list_price.setGravity(Gravity.CENTER_HORIZONTAL); list_price.setTextSize(14); items.addView(list_amount); items.addView(list_item); items.addView(list_description); items.addView(list_price); myTable.addView(items); total += allCoupons.get(i).getItemPrice() * allCoupons.get(i).getAmount(); } TableRow rowTotal = new TableRow(this); TextView labelTotal = new TextView(this); labelTotal.setText("Total"); labelTotal.setTextSize(18); labelTotal.setTextColor(Color.BLACK); labelTotal.setPadding(10, 0, 0, 0); TableRow.LayoutParams params = new TableRow.LayoutParams(); params.span = 3; TextView DisplayTotal = new TextView(this); double number = Math.round(total * 100); number = number / 100; DisplayTotal.setText(Double.toString(number)); DisplayTotal.setTextSize(18); DisplayTotal.setGravity(Gravity.CENTER_HORIZONTAL); DisplayTotal.setTextColor(Color.BLACK); rowTotal.addView(labelTotal, params); rowTotal.addView(DisplayTotal); myTable.addView(rowTotal); }
public void appendNeighborCellInfo(NeighboringCellInfo data) { TableRow tr = new TableRow(this); int color = Color.parseColor("#000000"); TextView label = new TextView(this); TableRow.LayoutParams params = new TableRow.LayoutParams(); params.span = 2; params.leftMargin = 10; params.rightMargin = 10; params.bottomMargin = 10; TableRow.LayoutParams params2 = new TableRow.LayoutParams(); params2.weight = 1; // params2.gravity=16; label.setLayoutParams(params); label.setText("Neighbor Cell Tower"); label.setTextSize(20); label.setTextColor(Color.parseColor("#909090")); // label.setTypeface(null, Typeface.BOLD); // label.setGravity(Gravity.CENTER); // label.setPadding(0, 10, 0, 0); tr.addView(label); tr.setLayoutParams(params); ((TableLayout) findViewById(R.id.info_table)).addView(tr, params); tr = new TableRow(this); label = new TextView(this); label.setLayoutParams(params); label.setText("Network type "); label.setTextSize(18); label.setTextColor(color); tr.setBackgroundResource(R.drawable.black_alpha); tr.addView(label); label = new TextView(this); label.setTextSize(18); label.setLayoutParams(params2); label.setText(getString(DCSConvertorUtil.networkTypeToStringId(data.getNetworkType()))); label.setTextColor(color); tr.addView(label); ((TableLayout) findViewById(R.id.info_table)).addView(tr, params); tr.setLayoutParams(params); tr = new TableRow(this); label = new TextView(this); label.setTextSize(18); label.setTextColor(color); tr.setBackgroundResource(R.drawable.black_alpha); label.setLayoutParams(params); label.setText("PSC "); tr.addView(label); label = new TextView(this); label.setText(data.getPsc() + ""); label.setLayoutParams(params2); label.setTextColor(color); tr.addView(label); ((TableLayout) findViewById(R.id.info_table)).addView(tr, params); tr.setLayoutParams(params); tr = new TableRow(this); label = new TextView(this); label.setLayoutParams(params); label.setText("Cell id "); label.setTextSize(18); label.setTextColor(color); tr.setBackgroundResource(R.drawable.black_alpha); tr.addView(label); label = new TextView(this); label.setLayoutParams(params); label.setText(data.getCid() + ""); label.setTextColor(color); label.setLayoutParams(params2); tr.addView(label); ((TableLayout) findViewById(R.id.info_table)).addView(tr, params); tr.setLayoutParams(params); tr = new TableRow(this); label = new TextView(this); label.setLayoutParams(params); label.setText("Area code "); label.setTextSize(18); label.setTextColor(color); tr.setBackgroundResource(R.drawable.black_alpha); tr.addView(label); label = new TextView(this); label.setText(data.getLac() + ""); label.setTextColor(color); label.setLayoutParams(params2); tr.addView(label); ((TableLayout) findViewById(R.id.info_table)).addView(tr, params); tr.setLayoutParams(params); tr = new TableRow(this); label = new TextView(this); label.setLayoutParams(params); label.setText("Signal Strength "); label.setTextSize(18); label.setTextColor(color); tr.setBackgroundResource(R.drawable.black_alpha); tr.addView(label); label = new TextView(this); label.setLayoutParams(params); label.setText(data.getRssi() + ""); label.setTextColor(color); label.setLayoutParams(params2); tr.addView(label); ((TableLayout) findViewById(R.id.info_table)).addView(tr, params); tr.setLayoutParams(params); }
private TableLayout getTable(Trigger trigger) { WindowManager mWinMgr = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE); int displayWidth = mWinMgr.getDefaultDisplay().getWidth(); TextView description = new TextView(ctx); description.setText(trigger.getDescription()); description.setTextColor(Color.BLACK); description.setTextSize(16); TextView hostName = new TextView(ctx); hostName.setText(trigger.getHost()); hostName.setTextColor(Color.BLACK); hostName.setTextSize(14); TextView age = new TextView(ctx); age.setText(trigger.getAgeTime()); age.setTextColor(Color.DKGRAY); age.setTextSize(12); age.setPadding(0, 10, 0, 0); // ##############################################################################3 TableLayout table = new TableLayout(ctx); // ##############################################################################3 TableRow row1 = new TableRow(ctx); if (!showage()) { TableRow.LayoutParams hostNameparam = new TableRow.LayoutParams(displayWidth / 2, LayoutParams.WRAP_CONTENT); hostNameparam.gravity = Gravity.LEFT; row1.addView(hostName, hostNameparam); TableRow.LayoutParams ageparam = new TableRow.LayoutParams(displayWidth / 3, LayoutParams.WRAP_CONTENT); ageparam.gravity = Gravity.RIGHT; row1.addView(age, ageparam); } else { TableRow.LayoutParams hostNameparam = new TableRow.LayoutParams(displayWidth - 40, LayoutParams.WRAP_CONTENT); hostNameparam.gravity = Gravity.LEFT; row1.addView(hostName, hostNameparam); } table.addView(row1, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); // ##############################################################################3 TableRow row2 = new TableRow(ctx); LinearLayout descripionLayout = new LinearLayout(ctx); TableRow.LayoutParams params = new TableRow.LayoutParams(); params.span = 2; descripionLayout.addView(description); descripionLayout.setLayoutParams(params); row2.addView(descripionLayout); table.addView(row2); return table; }