Just in case anyone is interested I found a thread in one of the other groups that makes a reference to HeaderViewListAdapter: http://groups.google.com/group/android-developers/browse_thread/thread/14617420938f6d70?pli=1
With this I created the following, its far from perfect but at least it loads!!!! <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ListView android:id="@+id/lvEntries" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearLayout> public class HelloAddHeaderview extends Activity { private ListView lv; private TextView tv; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); lv = (ListView) findViewById(R.id.lvEntries); tv = new TextView(this); tv.setText("Hello There!"); lv.addHeaderView(tv); lv.setAdapter(new ArrayAdapter<String> (this, android.R.layout.simple_list_item_1, COUNTRIES)); } static final String[] COUNTRIES = new String[] { "Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan" }; } 2009/8/17 chinchin <nchinn...@googlemail.com> > Hello, > I'm trying to modify the HelloListView example to use addHeaderView or > addFooterView. Unfortunately I am unable to get this working. Is > anyone able to provide any help? > Here is my code, thanks in advance. > > <?xml version="1.0" encoding="utf-8"?> > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/ > android" > android:orientation="vertical" > android:layout_width="fill_parent" > android:layout_height="fill_parent" > > > <TextView > android:id="@+id/textDisplay" > android:layout_width="fill_parent" > android:layout_height="wrap_content" > android:text="Hello!" > /> > </LinearLayout> > > public class HelloListView extends ListActivity { > private TextView test; > > /** Called when the activity is first created. */ > @Override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > > test = (TextView) findViewById(R.id.textDisplay); > > getListView().addHeaderView(test); > setListAdapter(new ArrayAdapter<String>(this, > android.R.layout.simple_list_item_1, COUNTRIES)); > getListView().setTextFilterEnabled(true); > } > > static final String[] COUNTRIES = new String[] { > "Afghanistan", "Albania", "Algeria", "American Samoa", > "Andorra", > "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", > "Argentina" > }; > > } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" group. To post to this group, send email to android-beginners@googlegroups.com To unsubscribe from this group, send email to android-beginners-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en -~----------~----~----~----~------~----~------~--~---