here is my code
TableRow taRow = new TableRow(ctx);
// taRow.setLayoutParams(tr.getLayoutParams());
TableLayout.LayoutParams tableRowParams=
new TableLayout.LayoutParams
(TableLayout.LayoutParams.FILL_PARENT,TableLayout.LayoutParams.WRAP_CONTENT);
int leftMargin=0;
int topMargin=30;
int rightMargin=0;
int bottomMargin=0;
tableRowParams.setMargins(leftMargin, topMargin, rightMargin, bottomMargin);
taRow.setLayoutParams(tableRowParams);
taRow.setPadding(0,10,10,10);
taRow.setGravity(Gravity.CENTER);
taRow.setVisibility(View.VISIBLE);
taRow.setBackgroundResource(R.drawable.bg_small_bar);
TextView Tv = new TextView(ctx);
// Tv.setLayoutParams(((TextView)
// (tr).getChildAt(0)).getLayoutParams());
Tv.setTextColor(Color.WHITE);
Tv.setGravity(Gravity.CENTER);
Tv.setText(mStandingLts.get(i).getPosition());
taRow.addView(Tv);
mTeamL = new LinearLayout(ctx);
ImageView mTeamImage = new ImageView(ctx);
TextView Tv1 = new TextView(ctx);
TableRow.LayoutParams dimParams = new TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
dimParams.setMargins(16, 16, 16, 16);
// taRow.setLayoutParams(dimParams);
mTeamL.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams viewDimen = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
Tv1.setLayoutParams(viewDimen);
LinearLayout.LayoutParams viewDimen1 = new LinearLayout.LayoutParams(64,48);
mTeamImage.setLayoutParams(viewDimen1);
Picasso.with(ctx).load(mStandingLts.get(i).getTeamLogo()).into(mTeamImage);
Tv1.setTextColor(Color.WHITE);
Tv1.setGravity(Gravity.CENTER);
Tv1.setText(mStandingLts.get(i).getTeam());
mTeamL.addView(mTeamImage);
mTeamL.addView(Tv1);
taRow.addView(mTeamL);
/*TextView Tv1 = new TextView(ctx);
Tv1.setTextColor(Color.WHITE);
Tv1.setGravity(Gravity.CENTER);
Tv1.setText(mStandingLts.get(i).getTeam());
taRow.addView(Tv1);*/
TextView Tv2 = new TextView(ctx);
Tv2.setTextColor(Color.WHITE);
Tv2.setGravity(Gravity.CENTER);
Tv2.setText(mStandingLts.get(i).getPlayed());
taRow.addView(Tv2);
TextView Tv3 = new TextView(ctx);
Tv3.setTextColor(Color.WHITE);
Tv3.setGravity(Gravity.CENTER);
Tv3.setText(mStandingLts.get(i).getWon());
taRow.addView(Tv3);
TextView Tv4 = new TextView(ctx);
Tv4.setTextColor(Color.WHITE);
Tv4.setGravity(Gravity.CENTER);
Tv4.setText(mStandingLts.get(i).getLost());
taRow.addView(Tv4);
TextView Tv7 = new TextView(ctx);
Tv7.setTextColor(Color.WHITE);
Tv7.setGravity(Gravity.CENTER);
Tv7.setText(mStandingLts.get(i).getPoints());
taRow.addView(Tv7);
tl.addView(taRow);
I have successfully created table layout dynamically ...
the problem is when i cleared the tablelyout and add the data dynamically ..i dono how to add the linear layout content which is having imageview and textview ...
for textview alone i have added
((TextView) (tr).getChildAt(0))
.setText(finalMStandingLts1.get(i).getPosition());
((TextView) (tr).getChildAt(1))
.setText(finalMStandingLts1.get(i).getTeam());
((TextView) (tr).getChildAt(2))
.setText(finalMStandingLts1.get(i).getPlayed());
((TextView) (tr).getChildAt(3))
.setText(finalMStandingLts1.get(i).getWon());
((TextView) (tr).getChildAt(4))
.setText(finalMStandingLts1.get(i).getLost());
((TextView) (tr).getChildAt(5))
.setText(finalMStandingLts1.get(i).getPoints());
and i got the solution right . . .Please guide me how to add this code
mTeamL = new LinearLayout(ctx);
ImageView mTeamImage = new ImageView(ctx);
TextView Tv1 = new TextView(ctx);
TableRow.LayoutParams dimParams = new TableRow.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
dimParams.setMargins(16, 16, 16, 16);
// taRow.setLayoutParams(dimParams);
mTeamL.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams viewDimen = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
Tv1.setLayoutParams(viewDimen);
LinearLayout.LayoutParams viewDimen1 = new LinearLayout.LayoutParams(64,48);
mTeamImage.setLayoutParams(viewDimen1);
Picasso.with(ctx).load(mStandingLts.get(i).getTeamLogo()).into(mTeamImage);
Tv1.setTextColor(Color.WHITE);
Tv1.setGravity(Gravity.CENTER);
Tv1.setText(mStandingLts.get(i).getTeam());
mTeamL.addView(mTeamImage);
mTeamL.addView(Tv1);
taRow.addView(mTeamL);
....