I am trying to create a ListView and add it to a custom ViewGroup. Here is my code:
public class HelloAndroid extends Activity { private static final String[] PHOTOS_NAMES = new String[] { "Lyon", "Livermore", "Tahoe Pier", "Lake Tahoe", "Grand Canyon", "Bodie" }; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView tv = new TextView(this); MyViewGroup vg = new MyViewGroup(this); ListView lv = new ListView(this); tv.setText("Some Text"); tv.layout(0, 0, 200, 40); vg.addView(tv); lv.layout(0, 40, 200, 200); final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, PHOTOS_NAMES); lv.setAdapter(adapter); vg.addView(lv); setContentView(vg); } } When I do this, I see the "Some Text" TextView (which I also am adding to my ViewGroup), but I don't see the ListView. Now if I set the ListView as the content view, (i.e. setContentView(lv)) it shows up. Does anyone have any idea what I am doing wrong? Thanks. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en