• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps arrayAdapter custom list view

I'm trying to create a custom list view from an remote XML file.

Currently, I have the list view populated with a single data line, but I want to customize the layout of the list.

In my list_item.xml, I have created two TextViews, id/toptext and bottomtext.

However, I can't figure out how to change my java file to populate those text items.

Here is the relevant info from the java file. Right now, you can see I just have it populating my row, without specifying top and or bottom text. How do I make the 'headers' fill in the top text, and the 'dates' in the bottom text?


Code:
List<String> headers = new ArrayList<String>(messages.size());
	    	for (Message msg : messages){
	    		headers.add(msg.getHeader());
	    	}
	    	List<String> dates = new ArrayList<String>(messages.size());
	    	for (Message msg : messages){
	    		dates.add(msg.getDate());
	    	}
	    	ArrayAdapter<String> adapter = 
	    		new ArrayAdapter<String>(
	    				this, 
	    				R.layout.list_item,
	    				headers
	    				);
	    	this.setListAdapter(adapter);
    	} catch (Throwable t){
    		Log.e("Leading Ideas",t.getMessage(),t);
    	}


Thanks for your help!
 
I've tried adding an additional setListAdapter:
Code:
    	setListAdapter(new ArrayAdapter<String>( 
	    				this, 
	    				R.layout.list_item,
	    				R.id.toptext, 
	    				headers	    				 
	    				));
	    	
	    	
	setListAdapter(new ArrayAdapter <String>(
	    				this,
	    				R.layout.list_item,
	    				R.id.bottomtext,
	    				dates
	    				));

However, this only returns the bottomtext, it doesn't return both.
 
Back
Top Bottom