stuart-d2
3/17/2014 - 4:13 AM

onCreate() With a Listview Adapter Note : Always put addFooterView before the setAdapter method -- my footerView was not displaying becaus

onCreate() With a Listview Adapter Note : Always put addFooterView before the setAdapter method -- my footerView was not displaying because of this. I assume this goes for any add###View method, bust come after the setAdapter() or error or won't display.

***basic onCreate

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); 
setContentView(R.layout.main);  


***
//onCreate, with adapters and adding view
@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		
		
        // TODO - Set up the app's user interface
        // This class is a ListActivity, so it has its own ListView
        // ListView's adapter should be a PlaceViewAdapter
		mAdapter = new PlaceViewAdapter (getApplicationContext());
		
		// TODO - add a footerView to the ListView
        // You can use footer_view.xml to define the footer
		TextView footer = (TextView) getLayoutInflater().inflate(R.layout.footer_view, null);
		ListView listView = getListView();
		listView.addFooterView(footer);
		listView.setAdapter(mAdapter);