Object as a source for the listview
I have an object submission which contains some informations which I would like to show in a list view. For example, in my object I can do this: submission.firstElement().getDate() and submission.firstElement().getTitle() which returns me a date and a title. My problem is: how to show those two elements (not only the first's) in a listview (two elements per list item). I have thinked on a for loop with the submission.size() but I have no idea how to get forward with. Thank you for your help.
You'll want to look at using a ListView and a ArrayAdapter. You could use a BaseAdapter but I have found a ArrayAdapter more than adequate for displaying a list of custom objects in a ListView. First create a layout that will be used to show the desired data per row in the ListView. In your case I assume that it will be two TextViews, one showing the title and date. Once done, create a ListAdapter and in it's constructor give it the layout for the row created above. Once done, use the getView() function to access the layout and populate the TextView's with the object's date and title. Have a look at the following links: http://developer.android.com/reference/android/widget/ArrayAdapter.html http://developer.android.com/reference/android/widget/BaseAdapter.html http://www.vogella.de/articles/AndroidListView/article.html EDIT: Ana, to aid you a bit further use a ListActivity as shown in this Google documentation: http://developer.android.com/reference/android/app/ListActivity.html. In the example given they use a SimpleListAdapter. However, for an ArrayAdapter the constructor is a little simpler: new ArrayListAdapter(this, R.layout.row_layout, listOfObjects); When using a ListActivity a layout does not need to be created as by default it includes one.
Get the (several) EditText values from list view and post as an array
Cannot Remove View From WindowManager - Multiple Threads
Two Picture and 5 textview overlapping in list view with relative layout
How to know Specificaly Name of the running apps in android?
FragmentActivity causing activity leaks (IntentReceiver) but not on MapActivity
Android layout dynamically issue
android - LinearLayout (Horizontal) - auto space between items
How to pass mp3 file from one activity to another as an intent
Android Application Lifecycle and back button
Unable to open debugger port : java.net.SocketException “Socket closed”
Youtube upload videos programmatically
Using Git/SCM as Application Persistence Layer
How to disable the list-item which I've just clicked in an listview in android?
Android MediaRecorder Multiple Files
How can I fix errors about imports in this code?
Can tinyXML-1 open files on Android?