I'm trying to make a listview that will have 3 lines of text one below the other (so 3 lines of text stacked on top of each other) that has the text content coming from 3 separate xml string-array files. The code I have so far is attached below. I have not added the 3rd xml string-array yet so no need to address that in your answer to me.
I've been looking all over for a few days to find out how to do this but simply cant find the answer. I've found how to add multi-line listviews inline with java code but I need the list items to be bound to 3 separate xml string arrays in order to make it easier to update them remotely as well as for speed purposes.
Any help out would be greatly appreciated.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String [] movie_name = getResources() .getStringArray(R.array.movie_name_array);
setListAdapter(new ArrayAdapter<String>(this, R.layout.movie_name, movie_name));
ListView lv = getListView();
lv.setTextFilterEnabled(true);
String [] movie_date = getResourc开发者_C百科es() .getStringArray(R.array.movie_date_array);
setListAdapter(new ArrayAdapter<String>(this, R.layout.movie_date, movie_date));
ListView lv1 = getListView();
lv1.setTextFilterEnabled(true);
You need to define your own layout adapter class in order to provide the listview with a proper view to display your data (ie, you array of 3 strings).
Check this example here : http://www.softwarepassion.com/android-series-custom-listview-items-and-adapters/
It's quite important to understand how to build the kind of components in android. Enjoy.
Stéphane
精彩评论