Code example for TableRow

Methods: addView, setClickable, setFocusable, setFocusableInTouchMode, setLongClickable, setOnClickListener, setOnLongClickListener, setPadding

0
	 *  
	 * @param lpanels 
	 */ 
	protected void addRow(SolarPanels lpanels) {
 
		TableRow row = new TableRow(parent);
 
		// Add our five columns (Name) 
		TextView tvName = new TextView(parent);
		tvName.setText(lpanels.getPanelType().toString());
		tvName.setGravity(Gravity.LEFT);
		tvName.setTextAppearance(parent, android.R.style.TextAppearance_Medium);
		row.addView(tvName);
 
		// Add Wattage 
		TextView tvWattage = new TextView(parent);
		tvWattage.setText(lpanels.getPanelType().getPanelWattage().toString() + "W");
		tvWattage.setGravity(Gravity.CENTER);
		tvWattage.setTextAppearance(parent, android.R.style.TextAppearance_Medium);
		row.addView(tvWattage);
 
		// Add Count 
		TextView tvCount = new TextView(parent);
		tvCount.setText(lpanels.getPanelCount().toString());
		tvCount.setGravity(Gravity.CENTER);
		tvCount.setTextAppearance(parent, android.R.style.TextAppearance_Medium);
		row.addView(tvCount);
 
		// Add Direction 
		TextView tvDirection = new TextView(parent);
		tvDirection.setText(String.format("%.2f", lpanels.getPanelDirection()));
		tvDirection.setGravity(Gravity.CENTER);
		tvDirection.setTextAppearance(parent, android.R.style.TextAppearance_Medium);
		row.addView(tvDirection);
 
		// Add Azimuth 
		TextView tvAzimuth = new TextView(parent);
		tvAzimuth.setText(String.format("%.2f", lpanels.getPanelAzimuth()));
		tvAzimuth.setGravity(Gravity.CENTER);
		tvAzimuth.setTextAppearance(parent, android.R.style.TextAppearance_Medium);
		row.addView(tvAzimuth);
 
		// Add our row to the table. 
		row.setPadding(3, 10, 3, 10);
		row.setLongClickable(true);
		row.setClickable(true);
		row.setFocusable(true);
		row.setFocusableInTouchMode(true);
		row.setOnLongClickListener(new OnLongClickListener() {
 
			@Override 
			public boolean onLongClick(View v) {
				setRowBackground(v);
				// get the panel information. 
				int index = panelTable.indexOfChild(v);
				longClickPanelEvent(v, panels.get(index - 1));
				// Unset the background. 
				v.setBackgroundColor(0);
				v.clearFocus();
				v.setSelected(false);
				return true; 
			} 
		}); 
		row.setOnClickListener(new OnClickListener() {
 
			@Override 
			public void onClick(View v) {
				// Clear all views backgrounds; 
				setRowBackground(v);