Заморозить один столбец таблицы по горизонтали
У меня есть действие, в котором я реализовал табличное представление, табличное представление имеет заголовок и тело, таблица с горизонтальной и вертикальной прокруткой.
ЭтоИсходный код деятельности:
public class ReportListActivity extends Activity {
TableLayout report_table;
TableRow tr_data;
int j = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_report_list);
report_table=(TableLayout) findViewById(R.id.report_table);
//---------------Table Header-----------------------------------------------
TableRow tr_head = new TableRow(this);
tr_head.setId(10);
tr_head.setBackgroundColor(Color.GRAY);
tr_head.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
TextView label_sr_no = new TextView(this);
label_sr_no.setId(20);
label_sr_no.setText("S.No.");
label_sr_no.setTextColor(Color.WHITE);
label_sr_no.setPadding(5,5,5,5);
tr_head.addView(label_sr_no);// add the column to the table row here
TextView label_test_name = new TextView(this);
label_test_name.setId(21);// define id that must be unique
label_test_name.setText("Test Name"); // set the text for the header
label_test_name.setTextColor(Color.WHITE); // set the color
label_test_name.setPadding(5,5,5,5); // set the padding (if required)
tr_head.addView(label_test_name); // add the column to the table row here
TextView label_test_date = new TextView(this);
label_test_date.setId(21);// define id that must be unique
label_test_date.setText("Date"); // set the text for the header
label_test_date.setTextColor(Color.WHITE); // set the color
label_test_date.setPadding(5,5,5,5); // set the padding (if required)
tr_head.addView(label_test_date); // add the column to the table row here
TextView label_ro = new TextView(this);
label_ro.setId(21);// define id that must be unique
label_ro.setText("R.O."); // set the text for the header
label_ro.setTextColor(Color.WHITE); // set the color
label_ro.setPadding(5,5,5,5); // set the padding (if required)
tr_head.addView(label_ro); // add the column to the table row here
TextView label_wo = new TextView(this);
label_wo.setId(21);// define id that must be unique
label_wo.setText("W.O."); // set the text for the header
label_wo.setTextColor(Color.WHITE); // set the color
label_wo.setPadding(5,5,5,5); // set the padding (if required)
tr_head.addView(label_wo); // add the column to the table row here
TextView label_lo = new TextView(this);
label_lo.setId(21);// define id that must be unique
label_lo.setText("L.O."); // set the text for the header
label_lo.setTextColor(Color.WHITE); // set the color
label_lo.setPadding(5,5,5,5); // set the padding (if required)
tr_head.addView(label_lo); // add the column to the table row here
TextView label_max = new TextView(this);
label_max.setId(21);// define id that must be unique
label_max.setText("Max."); // set the text for the header
label_max.setTextColor(Color.WHITE); // set the color
label_max.setPadding(5,5,5,5); // set the padding (if required)
tr_head.addView(label_max); // add the column to the table row here
TextView label_tm = new TextView(this);
label_tm.setId(21);// define id that must be unique
label_tm.setText("T.M."); // set the text for the header
label_tm.setTextColor(Color.WHITE); // set the color
label_tm.setPadding(5,5,5,5); // set the padding (if required)
tr_head.addView(label_tm); // add the column to the table row here
TextView label_rank = new TextView(this);
label_rank.setId(21);// define id that must be unique
label_rank.setText("Rank"); // set the text for the header
label_rank.setTextColor(Color.WHITE); // set the color
label_rank.setPadding(5,5,5,5); // set the padding (if required)
tr_head.addView(label_rank); // add the column to the table row here
report_table.addView(tr_head, new TableLayout.LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
//---------------Table Header-----------------------------------------------
//--------------------Table Body---------------------------
for (int i=1; i