I have TableLayout defined in the main.xml. Simple, 1 header row and 1 data
row.
<TableLayout android:id="@+id/*reportsTable*"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableRow>
<TextView android:id="@+id/DateOfReport"
android:text="Report Date"
android:textSize="14px"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView android:id="@+id/HeightHeading"
android:text="Height"
android:textSize="14px"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView android:id="@+id/WeightHeading"
android:text="Weight"
android:textSize="14px"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
<TableRow android:id="@+id/r1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<EditText android:id="@+id/dateOfReport"
android:text="DD/MM/YYYY"
android:textSize="11px"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button android:id="@+id/changeReportDate"
android:text="..."
android.textSize="12px"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<EditText android:id="@+id/height"
android:text="inCmOrInch"
android:textSize="11px"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText android:id="@+id/weight"
android:text="inKgOrPound"
android:textSize="11px"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableRow>
Now in the code I have a function defined that adds a new row.
private TableRow createNewTableRow(TableRow newRow){
newRow.setLayoutParams(new
LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)) ;
LinearLayout newLinearLayout = new LinearLayout(appActivity) ;
newLinearLayout.setOrientation(LinearLayout.HORIZONTAL);
newLinearLayout.setLayoutParams(new
LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT)) ;
EditText newReportDate = new EditText(appActivity) ;
newReportDate.setTextSize((float) 11.0);
newReportDate.setLayoutParams(new
LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)) ;
Button changeReportDate = new Button(appActivity) ;
changeReportDate.setTextSize((float) 12.0);
changeReportDate.setLayoutParams(new
LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)) ;
changeReportDate.setText("...");
EditText newHeight = new EditText(appActivity) ;
newHeight.setTextSize((float) 11.0);
newHeight.setLayoutParams(new
LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)) ;
EditText newWeight = new EditText(appActivity) ;
newWeight.setTextSize((float) 11.0);
newWeight.setLayoutParams(new
LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)) ;
newRow.addView(newLinearLayout);
newLinearLayout.addView(newReportDate);
newLinearLayout.addView(changeReportDate);
newRow.addView(newHeight);
newRow.addView(newWeight);
return newRow ;
}
Now, in the main code I call this function
if (v == (View) *addReportWidget*) {
TableRow newRow = new TableRow(appActivity, null);
*reportsTableWidget*.addView(createNewTableRow(newRow));
reportsTab.invalidate();
}
Now, the new row just wont show up. If I run the code in the debugger, and
watch *reportsTableWidget*.mChildren, everytime I click on *addReportWidget*,
a new entry shows up in the debugger watch variables.
What am I missing. Very frustating, please advice me.
Regards
Siddharth
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en