Can someone please explain to me why the below code does not display
anything? I am very confused.
import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
public class LayoutTest extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout mainLayout = new LinearLayout(this);
TableRow scoreRow = new TableRow(this);
TextView scoreLabel = new TextView(this);
TextView scoreText = new TextView(this);
TableLayout scoreTable = new TableLayout(this);
LinearLayout.LayoutParams mainLayoutParams = new
LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT);
LinearLayout.LayoutParams rowLayout = new
LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT);
LinearLayout.LayoutParams scoreLabelLayout = new
LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
LinearLayout.LayoutParams scoreTextLayout = new
LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
LinearLayout.LayoutParams scoreTableLayout = new
LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT);
mainLayout.setLayoutParams(mainLayoutParams);
scoreRow.setLayoutParams(rowLayout);
scoreLabel.setLayoutParams(scoreLabelLayout);
scoreText.setLayoutParams(scoreTextLayout);
scoreTable.setLayoutParams(scoreTableLayout);
scoreLabel.setText("Score: ");
scoreText.setText("0");
scoreRow.addView(scoreLabel);
scoreRow.addView(scoreText);
scoreTable.addView(scoreRow);
mainLayout.addView(scoreTable);
setContentView(mainLayout);
}
}
--
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