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.
Prevent Joda-Time to print negative numbers
Getting email from Facebook - FB android SDK
Pick an image and save it in custom folder
Android Insistent Notification Interrupted By SMS - How to make uninterruptable?
Android: Send notifications to all users
Android: Hiding soft keyboard when touching out of EditText
Appcompact EditText give Error on click of Cursor
No design library issue
coronasdk sqlite copy database to computer from device
Upload video to google drive using android api
Android ObjectAnimator+ValueAnimator laggy
Listview doesn't appear at Fragment after second compile
App crashing android security exception(missing internet permission?)
Hiding the navigation bar in Android, strange issue
Sorting rss feeds by publish date in android
How to Check is Android Download manger enabled? [duplicate]