Code example for TableRow

Methods: addView, setOnClickListener

0
				LayoutParams.FILL_PARENT, LayoutParams.MATCH_PARENT));
	} 
 
	void addRow(String param, final int i) {
 
		tr.setOnClickListener(new OnClickListener() {
 
			@Override 
			public void onClick(View arg0) {
				// fade the row color(black/gray to orange) when clicked 
				View row = ledgertable.getChildAt(i + 1);
 
				for (int j = 0; j < len; j++) {
					LinearLayout l = (LinearLayout) ((ViewGroup) row)
							.getChildAt(j);
					TextView t = (TextView) l.getChildAt(0);
					ColorDrawable drawable = (ColorDrawable)t.getBackground();
					System.out.println("color:"+drawable.getColor());
 
					ObjectAnimator colorFade = ObjectAnimator.ofObject(t, "backgroundColor", new ArgbEvaluator(), Color.parseColor("#FBB117"),drawable.getColor());
					colorFade.setDuration(100);
					colorFade.start();
				} 
 
				MainActivity.nameflag = true; 
 
				name = "Voucher details";
 
				MainActivity.searchFlag = true; 
 
				Object[] params = new Object[] { "Dr" };
				Accountlist = new ArrayList<String>();
 
				code = ledgerGrid_with_voucherCode.get(i).get(6).toString();
				String abc = ledgerGrid.get(i).get(1).toString();
 
				Object[] params1 = new Object[] { code };
 
				Object[] VoucherMaster = (Object[]) transaction
						.getVoucherMaster(params1, client_id);
				// System.out.println("i am new object"+VoucherMaster); 
 
				ArrayList otherdetailsrow = new ArrayList();
				for (Object row1 : VoucherMaster) {
					Object a = (Object) row1;
					otherdetailsrow.add(a.toString());// getting vouchermaster
														// details 
				} 
 
				String vtf = otherdetailsrow.get(2).toString();
 
				IntentToVoucher(vtf, params);
 
				Intent intent = new Intent(ledger.this, transaction_tab.class);
				intent.putExtra("flag", "from_ledger");
				// To pass on the value to the next page 
				startActivity(intent);
				// Toast.makeText(context,"name"+name,Toast.LENGTH_SHORT).show(); 
				return; 
 
			} 
		}); 
 
		label = new TextView(this);
		label.setText(param);
		label.setTextColor(Color.WHITE);
		label.setTextSize(18);
		// label.setBackgroundColor(Color.); 
		label.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
				LayoutParams.MATCH_PARENT));
		label.setBackgroundColor(Color.BLACK);
		label.setPadding(2, 2, 2, 2);
 
		Ll = new LinearLayout(this);
		LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
				LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
		params.setMargins(1, 1, 1, 1);
		// Ll.setPadding(10, 5, 5, 5); 
		Ll.addView(label, params);
		tr.addView((View) Ll);
 
	} 
 
	void IntentToVoucher(String vtf, Object[] params) {
		// for "Contra" voucher