简体   繁体   中英

Android TodoApp with ListView - list don't show up

I am writing a simple todo-app and working on the listView. Following the tutorial http://www.vogella.com/tutorials/AndroidListView/article.html#tutorial_ownadapter

My problem is that the list of todos don't show up in the listView. I get no exception or error that indicates it is not working.

I am working with the android sqlite database. When I start the activity, I write objects to the database and read them out, print them in log. So this part is working, you can see in the log.

Then I add the object to my own adapter and set the adapter to the listView.

I don't know what goes wrong. Here is my Project: https://github.com/Visores/de.fhb.android.todoapp/tree/master/MyTodoApp

and here is the log after starting activity the app:

   12-06 06:02:46.977: I/ActivityManager(1261): Start proc de.fhb.maus.android.mytodoapp for activity de.fhb.maus.android.mytodoapp/.activities.LoginActivity: pid=2576 uid=10064 gids={50064}
12-06 06:02:47.117: D/dalvikvm(2576): GC_FOR_ALLOC freed 36K, 4% free 3552K/3680K, paused 31ms, total 34ms
12-06 06:02:47.227: D/(2576): HostConnection::get() New Host Connection established 0xb7dc0a70, tid 2576
12-06 06:02:47.247: W/EGL_emulation(2576): eglSurfaceAttrib not implemented
12-06 06:02:47.257: D/OpenGLRenderer(2576): Enabling debug mode 0
12-06 06:02:47.567: I/ActivityManager(1261): Displayed de.fhb.maus.android.mytodoapp/.activities.LoginActivity: +609ms (total +7s839ms)
12-06 06:02:49.237: I/ActivityManager(1261): START u0 {cmp=de.fhb.maus.android.mytodoapp/.activities.TodoOverviewActivity} from pid 2576
12-06 06:02:49.277: D/dalvikvm(2576): GC_FOR_ALLOC freed 105K, 5% free 3960K/4140K, paused 2ms, total 3ms
12-06 06:02:49.287: D/dalvikvm(2576): GC_FOR_ALLOC freed 7K, 3% free 4264K/4368K, paused 2ms, total 2ms
12-06 06:02:49.297: I/dalvikvm-heap(2576): Grow heap (frag case) to 6.654MB for 2536932-byte allocation
12-06 06:02:49.317: D/dalvikvm(2576): GC_FOR_ALLOC freed 1K, 2% free 6740K/6848K, paused 18ms, total 18ms
12-06 06:02:49.387: D/Todos(2576): [Todo [id=1, name=one, description=one, isDone=false, isImportant=true, maturityDate=1231232], Todo [id=2, name=two, description=two, isDone=true, isImportant=true, maturityDate=1231232], Todo [id=3, name=three, description=three, isDone=true, isImportant=false, maturityDate=1231232], Todo [id=4, name=four, description=four, isDone=true, isImportant=true, maturityDate=1231232]]
12-06 06:02:49.427: W/EGL_emulation(2576): eglSurfaceAttrib not implemented
12-06 06:02:49.457: I/ActivityManager(1261): Displayed de.fhb.maus.android.mytodoapp/.activities.TodoOverviewActivity: +220ms

greetings Visores

activity: https://github.com/Visores/de.fhb.android.todoapp/blob/master/MyTodoApp/src/de/fhb/maus/android/mytodoapp/activities/TodoOverviewActivity.java

adapter: https://github.com/Visores/de.fhb.android.todoapp/blob/master/MyTodoApp/src/de/fhb/maus/android/mytodoapp/adapter/TodoArrayAdapter.java

layout for list row: https://github.com/Visores/de.fhb.android.todoapp/blob/master/MyTodoApp/res/layout/rowlayout.xml

layout of activity: https://github.com/Visores/de.fhb.android.todoapp/blob/master/MyTodoApp/res/layout/todo_overview.xml

consider changing

super(context, R.layout.rowlayout);

to

super(context, R.layout.rowlayout,todos);

or override getCount method

@Override
public int getCount() {
    // TODO Auto-generated method stub
    return todos.size();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM