Q:

Java/Android Arraylist giving addresses

I am trying to display a list in android using guidance from vogella's tutorial for sqlite in android :
this is part of my ProjectListDataSource class (This gets all data from the sqlite database):
  public List<ProjectList> getAllProjects() {
        List<ProjectList> projects = new ArrayList<ProjectList>();

        Cursor cursor = database.query(ProjectListHelper.TABLE_PROJECT_LIST,
            allColumns, null, null, null, null, null);

        cursor.moveToFirst();
        while (!cursor.isAfterLast()) {
            projects.add(cursorToProjectList(cursor));
          cursor.moveToNext();
        }
        // make sure to close the cursor
        cursor.close();

        return projects;
      }

private ProjectList cursorToProjectList(Cursor cursor) {
    ProjectList projList = new ProjectList();
    projList.setId(cursor.getLong(0));
    projList.setProjName(cursor.getString(1));
    projList.setProjComment(cursor.getString(2));
    projList.setProjDateTime(cursor.getString(3));

    return projList;
  }

And this is my activity class :
    public class ProjectListActivity extends ListActivity implements
    OnClickListener {
private static final String TAG = "ProjectListActivity";

private ProjectListDataSource datasource;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_projectlist);
    Log.d(TAG, "On Creat'd");
    init();

}

private void init() {
    // Getting data from database and adding to ListView
    datasource = new ProjectListDataSource(this);
    datasource.open();

    List<ProjectList> values = datasource.getAllProjects();

    ArrayAdapter<ProjectList> adapter = new ArrayAdapter<ProjectList>(this,
            android.R.layout.simple_list_item_activated_1, values);
    setListAdapter(adapter);
}

But on doing that I am getting unexpected result like this (see image) :
http://i.imgur.com/tQMooi8.png
But the database has records like this (see image):
http://i.imgur.com/HfY2azs.png
Can anyone please explain and give a solution as to why I cant get the list view to show the records as in the database... 
Thanks,
Viney 

A:

There are several issues here, depending on what you want to display.
The reason you're seeing the object string reference in your list is because you're using a plain ArrayAdapter, which simply calls toString() on the objects in the array.  If you override toString() in ProjectList, you can display what you want (though that's normally not the best way to solve this problem).
Another option which would allow you to keep using a plain ArrayAdapter would be to create an array of strings from the ProjectList objects of the data you want to display.  A bit wasteful, but that's another option.
What you normally want to do is extend ArrayAdapter and override getView().  In getView() you assign the data you want to display in the view.
If you want to display all the data from your ProjectList objects in a single list item, you'll also need to create a custom layout to represent the row.

