2 messages in com.googlegroups.android-beginners[android-beginners] trouble dynamical...
FromSent OnAttachments
kingkung24 Apr 2008 19:11 
Dan U.24 Apr 2008 19:25 
Subject:[android-beginners] trouble dynamically adding LinearLayout with 2 subviews
From:kingkung (king@gmail.com)
Date:04/24/2008 07:11:02 PM
List:com.googlegroups.android-beginners

Hi all,

I'm simply trying to programatically add an EditText and a Spinner on the same row. But everytime I run this code, all I see is the EditText object which has extended the width of the screen, and I don't see the Spinner at all.

Android seems to ignore the width and height (100,50) I set for the EditText.

When I run this code with the EditText commented out, all I see is the Spinner spanning the width of the screen (so it ignores the Spinner dimensions I set as well...)

Anyone know how I can fix this?

Thanks,

James

***********************************

LinearLayout ll = new LinearLayout(this); ll.setLayoutParams(new LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT));

EditText et = new EditText(this); et.setLayoutParams(new LayoutParams(100,50); ll.addView(et);

Spinner s = new Spinner(this); s.setLayoutParams(new LayoutParams(100,40); s.setAdapter(new ArrayAdapter<String>(this,R.layout.spinner_text,attrs)); ll.addView(s);

table.addView(ll,new TableLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT));

*************************************