The layout definition has to be programmatically? --- Em qua, 3/8/11, John <[email protected]> escreveu:
De: John <[email protected]> Assunto: [android-developers] Creating a Basic Layout Para: [email protected] Data: Quarta-feira, 3 de Agosto de 2011, 23:03 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 -- 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

