Question

I have a TableLayout where the datas are populated dynamically .But I dont know how to add a Column header for the table. Where my java class is

   tl=(TableLayout) findViewById(R.id.table);

            for(int k=0;k<i;k++)

            {
        tr[k]=new TableRow(getApplicationContext());



        tr[k].layout(0, 0, 0, 0);
        ids[k] = new TextView(getApplicationContext());
        ids[k].setText(loc_id[k]);
        ids[k].setTextColor(Color.WHITE);
        ids[k].setTextSize((float) 18);
        ids[k].setTypeface(null, 1);
        ids[k].setBackgroundColor(Color.TRANSPARENT);
        ids[k].setPadding(30, 15, 30, 15);
        loc[k] = new TextView(getApplicationContext());
        loc[k].setText(loc_name[k]);
        loc[k].setTextColor(Color.WHITE);
        loc[k].setTextSize((float) 18);
        loc[k].setTypeface(null, 1);
        loc[k].setBackgroundColor(Color.TRANSPARENT);
        loc[k].setPadding(30, 15, 30    ,15);


        tr[k].setPadding(0, 1, 0, 0);

        tr[k].addView(ids[k]);
        tr[k].addView(loc[k]);


        tl.addView(tr[k], new TableLayout.LayoutParams(
                LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            }
        }
    }


}`

Where I can set the Column header

Était-ce utile?

La solution

If I'm not wrong,, then for that you have to make TableLayout one for header and another for data. This link will help you

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top