Code example for TableRow

Methods: addView, setBackgroundColor, setId, setLayoutParams

0
		 
	} 
 
	 
	private void BaslikEkle(){ 
		TableRow tr_head = new TableRow(this);
		tr_head.setId(10);
		tr_head.setBackgroundColor(Color.GRAY);
		tr_head.setLayoutParams(new LayoutParams(
		LayoutParams.WRAP_CONTENT,
		LayoutParams.WRAP_CONTENT));
		 
		 
		TextView labelId = new TextView(this);
		labelId.setId(20);
		labelId.setText("ID");
		labelId.setTextColor(Color.WHITE);
		labelId.setPadding(5, 5, 5, 5);
        tr_head.addView(labelId);// add the column to the table row here
 
        TextView label_weight_kg = new TextView(this);
        label_weight_kg.setId(21);// define id that must be unique
        label_weight_kg.setText("IP"); // set the text for the header 
        label_weight_kg.setTextColor(Color.WHITE); // set the color
        label_weight_kg.setPadding(5, 5, 5, 5); // set the padding (if required)
        tr_head.addView(label_weight_kg); // add the column to the table row here
         
         
        TextView labelData = new TextView(this);
        labelData.setId(21);// define id that must be unique
        labelData.setText("DATA"); // set the text for the header 
        labelData.setTextColor(Color.WHITE); // set the color
        labelData.setPadding(5, 5, 5, 5); // set the padding (if required)
        tr_head.addView(labelData); // add the column to the table row here
         
        TextView labelUser = new TextView(this);
        labelUser.setId(21);// define id that must be unique
        labelUser.setText("USER"); // set the text for the header 
        labelUser.setTextColor(Color.WHITE); // set the color
        labelUser.setPadding(5, 5, 5, 5); // set the padding (if required)
        tr_head.addView(labelUser); // add the column to the table row here
         
        TextView labelPass = new TextView(this);
        labelPass.setId(21);// define id that must be unique
        labelPass.setText("PASS"); // set the text for the header 
        labelPass.setTextColor(Color.WHITE); // set the color
        labelPass.setPadding(5, 5, 5, 5); // set the padding (if required)
        tr_head.addView(labelPass); // add the column to the table row here
         
        try { 
            tlResults.addView(tr_head, new TableLayout.LayoutParams(
                    LayoutParams.MATCH_PARENT,
                    LayoutParams.WRAP_CONTENT));