Having difficulty in getting dynamically added table rows to show up - android

I am working on a screen that basically shows questions and answers in a grid format and I am putting them all into table rows dynamically. The problem I am having is that once I put in the first row (the header), the rest of the rows in the table do not show up. I first add the headers. This shows up.
protected void setupTableHeaders() {
TableRow tableRow = getNewTableRow();
tableRow.setTag(header);
TextView textView = new TextView(this);
GlobalVars.setupText(this,textView,32320); //Event
textView.setTextColor(R.color.black);
LayoutParams params = new LayoutParams(0,LayoutParams.WRAP_CONTENT,3.0f);
params.setMarginStart(50);
tableRow.addView(textView,params);
tableRow.addView(getNewDivider(),(new LayoutParams(0,LayoutParams.WRAP_CONTENT,.1f)));
Iterator it = mapQuestions.entrySet().iterator();
//first get all the answers
if (it.hasNext()) {
Map.Entry pair = (Map.Entry) it.next();
HolderQuestion holderQuestion = mapQuestions.get(pair.getKey());
//assume all answers sets for all questions on this screen are the same.
int i = 0;
for (HolderAnswer answer : holderQuestion.getListAnswers()) {
TextView textViewHeader = new TextView(this);
textViewHeader.setTextColor(R.color.black);
GlobalVars.setupText(this, textViewHeader, answer.getTextID());
tableRow.addView(textViewHeader, (new LayoutParams(0, LayoutParams.WRAP_CONTENT, .5f)));
if (i < holderQuestion.getListAnswers().size() - 1) {
tableRow.addView(getNewDivider(), (new LayoutParams(0, LayoutParams.WRAP_CONTENT, .1f)));
}
i++;
}
}
table1.addView(tableRow);
}
Then I add the questions and answers, which do not show up:
protected void setupRadioButtonAnswers() {
for (int i=0;i<holderQuestionMultis.size();i++) { //assume this is populated correctly
TableRow tableRow = getNewTableRow();
tableRow.setTag(answerRow);
TextView textView = new TextView(this);
textView.setTextColor(R.color.black);
GlobalVars.setupText(this,textView,holderQuestionMultis.get(i).getHolderQuestion().getTextID());
textView.setTag(textCell);
textView.setVisibility(View.VISIBLE);
LayoutParams params = new LayoutParams(0,LayoutParams.WRAP_CONTENT,3.0f);
params.leftMargin = 50;
tableRow.addView(textView,params);
tableRow.addView(getNewDivider(),(new LayoutParams(0,LayoutParams.WRAP_CONTENT,.1f)));
for (int j=0;j<holderQuestionMultis.get(i).getRadioButtons().size();j++) {
RadioButton radioButton = holderQuestionMultis.get(i).getRadioButtons().get(j);
radioButton.setVisibility(View.VISIBLE);
tableRow.addView(radioButton,(new LayoutParams(0,LayoutParams.WRAP_CONTENT,.5f)));
if (j< holderQuestionMultis.size()-1) {
tableRow.addView(getNewDivider(),(new LayoutParams(0,LayoutParams.WRAP_CONTENT,.1f)));
}
}
tableRow.setVisibility(View.VISIBLE);
table1.addView(tableRow);
}
}
And the two methods which get the radioButtons and table rows:
// table elements
protected TableRow getNewTableRow() {
TableRow tableRow = new TableRow(this);
TableLayout.LayoutParams tlparams = new TableLayout.LayoutParams(
TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT);
tableRow.setBackground(getResources().getDrawable(R.drawable.border_table_multi_grid));
tableRow.setLayoutParams(tlparams);
return tableRow;
}
protected RadioButton getRadioButton() {
RadioButton radioButton = new RadioButton(this);
radioButton.setBackground(getResources().getDrawable(R.drawable.radio_button_multigrid));
//radioButton.setButtonDrawable(R.color.transparent);
TableRow.LayoutParams params = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT);
radioButton.setLayoutParams(params);
return radioButton;
}
The tablelayout xml:
<TableLayout
android:id="#+id/table"
android:layout_width="match_parent"
android:layout_height="300dp"
android:orientation="horizontal"
android:layout_above="#+id/viewSpacer"
android:layout_below="#+id/lblSubQuestionText"
android:layout_marginBottom="15dp"
android:layout_marginRight="15dp"
android:layout_marginLeft="15dp"
android:layout_marginTop="15dp"
android:background="#drawable/border_table_multi_grid">
What am I missing? Is the first table header row covering up the other rows? Why do they not appear?

It turns out that this code:
tableRow.addView(getNewDivider(),(new LayoutParams(0,LayoutParams.WRAP_CONTENT,.1f)));
Was the culprit which consisted of adding a LinearLayout containing a view. Just adding the view alone solved the problem.

Related

OnClickListener not working android

I have programmatically create the table in android.
In that table, each row has 2 text views, 1 edit text and 1 button.
I have to set the OnClickListner to the button to remove that particular row.
But OnClickListner is not working. Already I have implemented this process without edit text.It gives below warning message. how to solve this ? W/InputMethodManagerService﹕ Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#133707c3 attribute=null, token = android.os.BinderProxy#30f60fac*****
public void addRows(List MenuItem rowdata, boolean toggleColor) {
Log.i("addrows", "CP1" + rowdata);
tr = new TableRow(this);
TableLayout.LayoutParams lp =
new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT);
tr.setLayoutParams(lp);
TextView Name = new TextView(this);
Name.setText(rowdata.getDishname());
Name.setTextSize(18);
Name.setTextColor(Color.parseColor("#222C31"));
Name.setTypeface(custom);
Name.setPadding(0,10,0,10);
if(toggleColor) {
Name.setBackground(getDrawable(R.drawable.border2));
}else {
Name.setBackground(getDrawable(R.drawable.border));
}
TableRow.LayoutParams nameparams =
new TableRow.LayoutParams(0, TableRow.LayoutParams.MATCH_PARENT, 3.2f);
Name.setLayoutParams(dishnameparams);
Name.setGravity(Gravity.CENTER);
tr.addView(Name); // Adding textView to tablerow.
TextView JobInfo = new TextView(this);
JobInfo.setText(rowdata.getDishname());
JobInfo.setTextSize(18);
JobInfo.setTextColor(Color.parseColor("#222C31"));
JobInfo.setTypeface(custom);
JobInfo.setPadding(0,10,0,10);
if(toggleColor) {
JobInfo.setBackground(getDrawable(R.drawable.border2));
}else {
JobInfo.setBackground(getDrawable(R.drawable.border));
}
TableRow.LayoutParams nameparams =
new TableRow.LayoutParams(0, TableRow.LayoutParams.MATCH_PARENT, 3.2f);
JobInfo.setLayoutParams(dishnameparams);
JobInfo.setGravity(Gravity.CENTER);
tr.addView(JobInfo); // Adding textView to tablerow.
EditText SplComment = new EditText(this);
SplComment.setText(rowdata.getSplComment());
SplComment.setTextSize(18);
SplComment.setTextColor(Color.parseColor("#222C31"));
SplComment.setTypeface(custom);
SplComment.setPadding(0, 10, 0, 10);
if(toggleColor) {
SplComment.setBackground(getDrawable(R.drawable.border2));
}else {
SplComment.setBackground(getDrawable(R.drawable.border));
}
TableRow.LayoutParams SplCommentparams =
new TableRow.LayoutParams(3, TableRow.LayoutParams.MATCH_PARENT, 2.65f);
// SplCommentparams.setMargins(0, 0, 10, 0);
SplComment.setLayoutParams(SplCommentparams);
SplComment.setGravity(Gravity.CENTER);
tr.addView(SplComment); // Adding Edit text to tablerow.
LinearLayout LL3Setup = new LinearLayout(this);
LL3Setup.setOrientation(LinearLayout.VERTICAL);
LL3Setup.setLayoutParams(new TableRow.LayoutParams(5, TableRow.LayoutParams.MATCH_PARENT, 0.63f));
//LL1Setup.setPadding(20, 20, 20, 20);
LL3Setup.setGravity(Gravity.CENTER);
if(toggleColor) {
LL3Setup.setBackground(getDrawable(R.drawable.border2));
}else {
LL3Setup.setBackground(getDrawable(R.drawable.border));
}
Button DeleteBtn = new Button(this);
DeleteBtn.setText("D");
DeleteBtn.setTextColor(Color.WHITE);
DeleteBtn.setLayoutParams(new TableRow.LayoutParams(50, 40));
DeleteBtn.setTypeface(custom);
DeleteBtn.setAllCaps(false);
DeleteBtn.setTextSize(12);
DeleteBtn.setBackground(getDrawable(R.drawable.btn_vmd));
DeleteBtn.setOnClickListener(DeleteListener);
DeleteBtn.setClickable(true);
DeleteBtn.setGravity(Gravity.CENTER);
LL3Setup.addView(DeleteBtn);
tr.addView(LL3Setup); // Adding button to tablerow.
// Add the TableRow to the TableLayout
MainTableFinish.addView(tr, new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,
TableRow.LayoutParams.MATCH_PARENT));
}
Button Listner code:
DeleteListener = new View.OnClickListener() {
#Override
public void onClick(View v) {
Log.i("Delete Row", "Yes");
UpdateTable();
}
};
Declaration:
View.OnClickListener DeleteListener;
I Just found the possible solution from a old stackoverflow thread.
Please Try
Delete row dynamically from table layout in android

How to add multiple columns in a row of an android table layout

I have a custom list with name,age and grade .I want to loop through the list and show the contents in a table layout.Each row will have following attributes.Row will have some kind of styling
Name,
Age,
Age_Value,
Grade,
Grade_Value
Here Age and Grades are just a label.Given below is a sample table
Dolly
Age
23
Grade
A+
Roman
Age
22
Grade
C
Ben
Age
23
Grade
B+
I want to add these details to the Table layout in my layout dynamically.
Here is the code im trying
for(int j=0;j<_attributeList.size();j++)
{
TableRow tr = new TableRow(MyActivity.this);
tr.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
TextView tvName = new TextView(MyActivity.this);
tvName.setPadding(3,0,0,0);
tvName.setText(_attributeList.get(j).getName() +" : ");
tr.addView(tvName);
TextView tvAgeL = new TextView(MyActivity.this);
tvAgeL .setText("Age");
tr.addView(tvAgeL );
TextView tvAgeValue = new TextView(MyActivity.this);
tvAgeValue .setPadding(3,0,0,0);
tvAgeValue .setText(_attributeList.get(j).getValue() +" : ");
tr.addView(tvAgeValue );
attributeTable.addView(tr, new TableLayout.LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
}
}
Since these items are adding to the same row im getting results in a single line. How can i show them in seperate rows
You should try like this
Code
for(int i = 0; i < _attributeList.size();i++){
TableRow newRow = new TableRow(getApplicationContext());
newRow.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
newCheckBox = new CheckBox(getApplicationContext());
TextView feeTypeText = new TextView(getApplicationContext());
feeTypeText.setText(jsonObj.getString("feeType"));
feeTypeText.setTextColor(Color.BLACK);
feeTypeText.setTextSize(16f);
feeTypeText.setTypeface(tf);
TextView dueAmountText = new TextView(getApplicationContext());
dueAmountText.setText(jsonObj.getString("dueAmount"));
dueAmountText.setTextColor(Color.BLACK);
dueAmountText.setTextSize(16f);
dueAmountText.setTypeface(tf);
TextView dueDateText = new TextView(getApplicationContext());
dueDateText.setText(jsonObj.getString("dueDate"));
dueDateText.setTextColor(Color.BLACK);
dueDateText.setTextSize(16f);
dueDateText.setTypeface(tf);
newRow.addView(newCheckBox,(new LayoutParams(0,LayoutParams.WRAP_CONTENT,0.8f)));
newRow.addView(feeTypeText,(new LayoutParams(0,LayoutParams.WRAP_CONTENT,0.8f)));
newRow.addView(dueAmountText,(new LayoutParams(0,LayoutParams.WRAP_CONTENT,1.0f)));
newRow.addView(dueDateText,(new LayoutParams(0,LayoutParams.WRAP_CONTENT,1.0f)));
attributeTable.addView(newRow);
}
you can add like this way...here i added TableRow Programatically in which i added textView.
addtree.setOnClickListener(new OnClickListener()
{
#Override
public void onClick(View arg0)
{
tr1 = new TableRow(YourActivity.this);
tr1.setClickable(true);
tr1.setId(jj);
tr1.setPadding(0, 5, 0, 5);
Log.d("id", "id is......"+tr1.getId());
LinearLayout.LayoutParams layoutParams=new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
TextView textview = new TextView(New_Quote_Activity.this);
textview.setText("Job "+jj);
textview.setTextColor(Color.BLACK);
textview.setTypeface(null, Typeface.BOLD);
textview.setTextSize(14);
textview.setPadding(5, 0, 0, 0);
View vv=new View(New_Quote_Activity.this);
vv.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,1));
vv.setBackgroundResource(R.color.viewcolor);
View vv1=new View(New_Quote_Activity.this);
vv1.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,1));
vv1.setBackgroundResource(R.color.viewcolor);
tr1.addView(textview);
table_crete_invoice.addView(vv1);
table_crete_invoice.addView(tr1,layoutParams);
table_crete_invoice.addView(vv);
}

ANdroid: Dynamicly add Image Buttons to rows in Table Layout

I need to add a number of rows to my Table layout and to each row I need to add two Image Buttons. Number of rows can be different each time I start the Activity - I look into a SQLite database and for each row in the database I need to add an Image Button. And there will be two Image Buttons in each row of Table layout. So far, I have this code:
db.open();
int count = db.getCount();
boolean newRow = true;
for (int i = 0; i < count; i++) {
if (newRow == true) {
newRow = false;
row = new TableRow(this);
row.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
}
ImageButton button = new ImageButton(this);
row.addView(button);
tableLayout.addView(row);
}
db.close();
TableRow row is defined above this block of code simply as variable for this Activity. My Table layout (tableLayout in code) is defined in XML code of the Activity layout:
<TableLayout
android:id="#+id/tableLayoutContacts"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TableLayout>
The code crashes at the line
tableLayout.addView(row);
I wasnt able to resolve this. Any ideas? Thanks!!
I think the problem is different
It seems that Your code will have only one row and you are adding that row again and again to tableLayout as shown below.
tableLayout.addView(row);
This will lead to IllegalStateException at addViewInner Function of ViewGroup
try this
db.open();
int count = db.getCount();
boolean newRow = false;
for (int i = 0; i < count; i++) {
if (i % 2 == 0)
newRow = true;
if (newRow == true) {
newRow = false;
row = new TableRow(this);
row.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
tableLayout.addView(row);
}
ImageButton button = new ImageButton(this);
row.addView(button);
}
db.close();

Populating Table Layout using JSON String

I have a JSON String returned by my web service as follows:
{"checkrecord"[{"rollno":"abc2","percentage":40,"attended":12,"missed":34}],"Table1":[]}
The above String represents my dataset. I have converted the String to a JSON Object and I now want to put the data in the String into a TableLayout.
I want the table to be like this when displayed on android app:
rollno percentage attended missed
abc2 40 12 34
This is the code I am using as of now :
//json processing code
public void jsonprocessing(String c)
{
try
{
JSONObject jsonobject = new JSONObject(c);
JSONArray array = jsonobject.getJSONArray("checkrecord");
int max = array.length();
for (int j = 0; j < max; j++)
{
JSONObject obj = array.getJSONObject(j);
JSONArray names = obj.names();
for (int k = 0; k < names.length(); k++)
{
name = names.getString(k);
value= obj.getString(name);
createtableLayout();
}
}
}
catch (JSONException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//create table layout
public void createtableLayout()
{
Log.d("values",value); //I am able to see the values abc2,40,12 and 34 over here in logcat
TableLayout t= (TableLayout)findViewById(R.id.tablelayout);
TableRow r1=new TableRow(this);
r1.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
TextView t1 = new TextView(this);
t1.setText(value);
t1.setTextColor(Color.BLACK);
t1.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
r1.addView(t1);
t.addView(r1, new TableLayout.LayoutParams( LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
}
My TableLayout contains a button and a EditText as the first TableRow. After I click the button I get the JSON String. So I need to insert 2 TableRows dynamically after that as per my requirement.
My xml as of now is as follows:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/tablelayout"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:background="#000044">
<TableRow>
<EditText
android:id="#+id/edittext"
android:width="200px" />
<Button
android:id="#+id/button"
android:text="Check Record"/>
</TableRow>
</TableLayout>
So my problem is how to add those 2 extra TableRows so as to populate them with the String values ?
My code isn't working fine. I am not able to get the required output.
Can anyone help me in this?
Thanks
you can use multicolumn listview for your purpose,
Parse the JSON response and get values into different strings and use this blog for your purpose
Multicolumn Listview
You, probably, can define those 2 more rows in your XML and make them initially invisible. Then upon receiving your data put your data in those rows and make them visible.
// Every UI object must have a layout parameter
int widthContent = RelativeLayout.LayoutParams.WRAP_CONTENT;
int heightContent = RelativeLayout.LayoutParams.WRAP_CONTENT;
// Create relative layout
RelativeLayout.LayoutParams rlParamsName = new RelativeLayout.LayoutParams(widthContent,heightContent);
// Create table row layout
int trWidthContent = TableRow.LayoutParams.WRAP_CONTENT;
int trHeightContent = TableRow.LayoutParams.WRAP_CONTENT;
TableRow.LayoutParams trLayout = new TableRow.LayoutParams(trWidthContent, trHeightContent);
// Create a linear layout to add new object as vertical
LinearLayout objLinearLayout = new LinearLayout(context);
objLinearLayout.setOrientation(LinearLayout.VERTICAL);
// Add number of categories to menu
for (int i = 0; i < SpecialCategories.length(); i++) {
try {
// Json for special categories
JSONObject jsonData = SpecialCategories.getJSONObject(i);
// Get name and count of category
String specialCategoryNames = jsonData.getString("label").toString();
String specialCategoryCount = jsonData.getString("coupon_count").toString();
final TableRow tr = new TableRow(this);
tr.setLayoutParams(trLayout);
tr.setId(i);
//tr.setBackgroundColor(0xFFBEBEBE);
// What is the text view for category name
TextView categoryName = new TextView(this);
categoryName.setPadding(8, 8, 8, 8);
categoryName.setTextSize(18);
categoryName.setLayoutParams(trLayout);
categoryName.setText(specialCategoryNames);
categoryName.setId(i);
categoryName.setTypeface(null, Typeface.BOLD);
categoryName.setTextColor(0xFF000000);
// What is count for category
TextView categoryCount = new TextView(this);
categoryCount.setPadding(7, 8, 8, 8);
categoryCount.setLayoutParams(trLayout);
categoryCount.setBackgroundColor(Color.WHITE);
categoryCount.setText("("+specialCategoryCount+")");
// Add disclosure image to row
ImageView objDrawLineImageView = new ImageView(this);
objDrawLineImageView.setPadding(280, 19, 6, 6);
objDrawLineImageView.setImageResource(R.drawable.disclosure);
objDrawLineImageView.setLayoutParams(trLayout);
// Add name of category
tr.addView(categoryName);
// Add count for category
tr.addView(categoryCount);
// Add disclosure back to table row
tr.addView(objDrawLineImageView);
// Add table row into linear layout
objLinearLayout.addView(tr);
//Add Row End Line to Linear layout
ImageView rowEndLine = new ImageView(context);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,2);
params.setMargins(0, 5, 0, 0);
rowEndLine.setLayoutParams(params);
rowEndLine.setBackgroundColor(0xFFBEBEBE);
// Add end line image to linear layout
objLinearLayout.addView(rowEndLine);
// What happen when user click on table row
tr.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
Toast.makeText(Main.this, ""+tr.getId(),Toast.LENGTH_SHORT).show();
Log.e("TAG", " clicked ID: "+tr.getId());
}
});
} catch (Exception e) {
e.printStackTrace();
}// end try
}// end for SpecialCategories.length()
//Add button number two to the activity.
RelativeLayout objRelativeLayout = (RelativeLayout)findViewById(R.id.row_special);
objRelativeLayout.addView(objLinearLayout);

Extending TableLayout class - adding rows

I am trying to extend the TableLayout class, such that rows will be populated automatically by the class. The issue I am having is the rows that I add inside the custom class do not display.
Ex. within the Activity:
private TextView getTableCell(String text) {
TextView tv = new TextView(this);
tv.setText(text);
tv.setLayoutParams(new LayoutParams(
LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
return tv;
}
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
DatasetTableLayout table = (DatasetTableLayout) findViewById(R.id.table);
TableRow tr = new TableRow(this);
tr.addView(getTableCell("activity1"));
tr.addView(getTableCell("activity2"));
tr.addView(getTableCell("activity3"));
table.addView(tr);
This successfully adds a row to the table. However, within my custom class:
private TextView getTableCell(String text) {
TextView tv = new TextView(context);
tv.setText(text);
tv.setLayoutParams(new LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
return tv;
}
private void update() {
TableRow tr = new TableRow(context);
tr.addView(getTableCell("class1"));
tr.addView(getTableCell("class2"));
tr.addView(getTableCell("class3"));
addView(tr);
}
does not successfully add a row. Well, it does add a row, as getChildCount(), and getChildAt() do return this row - but it does not get displayed.
Am I missing something?
#theresia (Can't seem to format text if I add a comment):
It does appear that it adds the TableRow:
for(int i = 0; i < getChildCount(); i++) {
TableRow row = (TableRow) getChildAt(i);
for(int j = 0; j < row.getChildCount(); j++) {
TextView tv = (TextView) row.getChildAt(j);
Log.e("DatasetTableLayout-data", tv.getText().toString() + " ");
}
}
gives me:
01-24 11:03:31.668: ERROR/DatasetTableLayout-data(1624): activity1
01-24 11:03:31.677: ERROR/DatasetTableLayout-data(1624): activity2
01-24 11:03:31.698: ERROR/DatasetTableLayout-data(1624): activity3
01-24 11:03:31.698: ERROR/DatasetTableLayout-data(1624): class1
01-24 11:03:31.698: ERROR/DatasetTableLayout-data(1624): class2
01-24 11:03:31.727: ERROR/DatasetTableLayout-data(1624): class3
My guess would be something along this line: addView(tr); Does it successfully add your TableRow to TableLayout?
Edit:
TableLayout tb = new TableLayout(this);
TableRow tr = new TableRow(this);
TextView tv = new TextView(this);
tv.setText("row");
tr.addView(tv);
tb.addView(tr); // this is what I mean
setContentView(tb);
Your code for creating rows works fine, but if you haven't add it to the table, and later on, add the table to the parent view as well, your rows wouldn't get displayed.

Categories

Resources