tags:

views:

718

answers:

1

Hi, I am using Spinner control in my application and my Code is

    Spinner s1=new Spinner(this);
    s1.setLayoutParams(new LayoutParams(100,30));
    ArrayAdapter adapter=new ArrayAdapter(this, android.R.layout.simple_expandable_list_item_1); 
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    adapter.add("One");
    adapter.add("Two");
    adapter.add("Three");
    s1.setAdapter(adapter);

This will work fine in linearLayout .when I use the code in the TableLayout, the control is not displayed.I have to generate dynamic layout so i am not using the XML part,only through Java code i am adding the contorls.

TableLayout tl=new TableLayout(this);
TableRow tr=new TableRow(this);
tr.addView(s1);
tl.addView(tr);

All the components gets added other than Spinner.

So please anyone give some solution for this.

A: 

Now add your tl to ScrollView using:

ScrollView sv = new Scrollview(this); sv.addview(tl); setContentview(sv);

It should work.

Ranjeet