Is your goal to define a new Layout? If it is, you should extend the LinearLayout, for example, and do whatever you want...
If you do not know how to define your layout using XML what makes you believe that you can do it programmatically? Maybe is this what isn't working. You should try using XML. If those variables are necessary for the layout, you should try the "set" methods. Your code is really estrange to read, and I, with my experience, your code could be expressed with the xml layout file without any loss. --- Em qua, 3/8/11, John <[email protected]> escreveu: De: John <[email protected]> Assunto: RE: [android-developers] Creating a Basic Layout Para: [email protected] Data: Quarta-feira, 3 de Agosto de 2011, 23:19 In the program I’m trying to do this in I have my own custom object that extends View. The constructor takes some programmatically set variables. I’m not opposed to using XML but I had up to this point been controlling my layout programmatically and wasn’t sure how to get my custom object with the variables required by the constructor in an XML layout. From: [email protected] [mailto:[email protected]] On Behalf Of Giorgio Torres Sent: Wednesday, August 03, 2011 6:12 PM To: [email protected] Subject: Re: [android-developers] Creating a Basic Layout 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:03Can 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 -- 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

