I'm providing LayoutParams - not of the TableLayout variety, however I
did this in a different place and it worked fine.
Here is the code I've used:
//INFLATE SCORES TABLE FROM SCORESDIALOG
View highScoresView = factory.inflate(R.layout.scoresdialog, null);
TableLayout scoreTable = (TableLayout) highScoresView.findViewById
(R.id.scoreTable);
//DEFINE A DIVIDER, AND VARIOUS LAYOUT PARAMETERS
LayoutParams fillwrap = new LayoutParams
(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
LayoutParams dividerparams = new LayoutParams
(2,LayoutParams.WRAP_CONTENT);
//GENERATE AND FILL THE HIGH SCORES TABLE
String instr;
while ((instr = scoreReader.readLine())!=null){
String nameplusscore[] = instr.split("-");
TableRow newScoreRow = new TableRow(this);
TextView playername = new TextView(this);
playername.setText(nameplusscore[0]);
TextView playerscore = new TextView(this);
playerscore.setText(nameplusscore[1]);
View dividerview = new View(this);
Log.d("table constructor","adding view to row");
newScoreRow.addView(playername, fillwrap);
Log.d("table constructor","adding view2 to row");
newScoreRow.addView(dividerview, dividerparams);
Log.d("table constructor","adding view3 to row");
newScoreRow.addView(playerscore,fillwrap);
Log.d("table constructor","adding row to table");
scoreTable.addView(newScoreRow,fillwrap);
}
scoresIn.close();
//CREATE A DIALOG CONTAINING THE TABLE
new AlertDialog.Builder(this)
.setView(highScoresView)
.setNeutralButton("Done", new DialogInterface.OnClickListener(){
public
void onClick(DialogInterface dlg, int btn){
// nothing to do.
}
})
.setCancelable(false)
.show();
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" 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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---