Up vote 4 down vote favorite share g+ share fb share tw.
I have seen many posts regarding dynamically adding table rows, but I am not sure what I'm missing. When I execute the following, nothing is displayed (aside from application title bar). My Layout: My Activity: protected void onCreate(Bundle savedInstanceState) { super.
OnCreate(savedInstanceState); setContentView(R.layout. Table_view); TableLayout tableLayout = (TableLayout) findViewById(R.id. Tvt_tableview); TableRow tableRow = new TableRow(this); tableRow.
SetLayoutParams(new TableRow. LayoutParams(TableRow.LayoutParams. FILL_PARENT, TableRow.LayoutParams.
WRAP_CONTENT)); TextView column1 = new TextView(this); column1. SetLayoutParams(new ViewGroup. LayoutParams(ViewGroup.LayoutParams.
FILL_PARENT, ViewGroup.LayoutParams. WRAP_CONTENT)); column1. SetBackgroundColor(Color.
YELLOW); column1. SetTextColor(Color. BLUE); column1.
SetText("Col1 Value"); tableRow. AddView(column1); TextView column2 = new TextView(this); column2. SetLayoutParams(new ViewGroup.
LayoutParams(ViewGroup.LayoutParams. FILL_PARENT, ViewGroup.LayoutParams. WRAP_CONTENT)); column2.
SetBackgroundColor(Color. RED); column2. SetTextColor(Color.
GREEN); column2. SetText("Col2 Value"); tableRow. AddView(column2); tableLayout.
AddView(tableRow, new TableLayout. LayoutParams(TableLayout.LayoutParams. FILL_PARENT, TableLayout.LayoutParams.
WRAP_CONTENT)); //tl. RefreshDrawableState(); //findViewById(R.id. Tvt_scroll_relative).
RefreshDrawableState(); } java android tablelayout tablerow link|improve this question edited Sep 25 '11 at 16:28 asked Sep 24 '11 at 20:36CrackerJack91,6061319 100% accept rate.
Interesting. This all looks good to me (not that I am absolutely sure of anything here...). I will recommend trying to dynamically add other TextView's to the other layouts above the TableLayout.
See if you can get something to show up. Let us know how it works out. – nicholas.
Hauschild Sep 24 '11 at 20:48 remove the line tableRow.setLayoutParams(); after you have instantiated TableRow, it should work I think. Let me know if this works, so that I can post it as a solution. – Yashwanth Kumar Sep 24 '11 at 21:35 @Yashwanth Kumar, removing that alone did not help.
Changing ViewGroup. LayoutParams to TableRow. LayoutParams or removing them altogether does resolve the issue.
– CrackerJack9 Sep 25 '11 at 16:49.
Change the two references ViewGroup. LayoutParams to TableRow. LayoutParams and it should work.
Adding layout params to a widget requires that the LayoutParams are a inner class of the surrounding layout container.
– CrackerJack9 Sep 25 '11 at 16:52 I had the same problem and discovered it after a some experiencing. I would be interested in some reference, too. – mikegr Sep 26 '11 at 7:00.
I think this has something to do with you setting the layout params to the TextViews. If you remove those definitions the info appears. Also if you take a look at the official documentation for TableRow you can see: The children of a TableRow do not need to specify the layout_width and layout_height attributes in the XML file.
TableRow always enforces those values to be respectively MATCH_PARENT and WRAP_CONTENT.
Not entirely true, as you can set TableRow.LayoutParams. Span, in which case you will need to set the LayoutParams. – CrackerJack9 Sep 25 '11 at 19:14.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.