Hi all!
I've managed to show existing user in a textview. But it can only show one at a time so I decided to use listview.
package log1.log2;
import android.app.ListActivity;
import android.database.Cursor;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.SimpleCursorAdapter;
public class AdminMain extends ListActivity {
DBAdapter db = new DBAdapter(this);
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.listview);
db = new DBAdapter(this);
db.open();
Cursor c = db.getAllUser();
while (c.moveToNext()){
setListAdapter(new SimpleCursorAdapter(this,
R.layout.adminmain, c,
new String[] { "Username" },
new int[] {R.id.txtUser}));
}
db.close();
}
}
But I received this error message from the logcat.
08-19 04:22:49.331: ERROR/AndroidRuntime(918): java.lang.RuntimeException: Unable to start activity ComponentInfo{log1.log2/log1.log2.AdminMain}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
I have added listview in listview.xml. I do not understand why the error msg tells me that.
I hope to receive helpful replies soon! Thank you very much!
-Dayne
Edited
Hello again
For my xml, I got two xml file to make the listview work. First is listview.xml
and second is adminmain.xml
. For listview.xml
, i've placed only listview. And for adminmain.xml
, I placed textview.
listview.xml
:
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
android:id="@+id/widget0"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<ListView android:id="@+id/ListView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</AbsoluteLayout>
adminmain.xml
:
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
android:id="@+id/widget0"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background = "@drawable/image"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<TextView
android:id="@+id/txtUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ff000000"
android:text="USERNAMES HERE"
android:layout_x="100px"
android:layout_y="102px"/>
</AbsoluteLayout>
I've tried swapping the R.layout
. The same error message appears.
I hope somebody can give me a good tip soon. Thank you for reading my post.
-Dayne
After Editing
Here's the message from the log cat:
08-20 04:06:45.326: INFO/ActivityManager(587): Start proc log1.log2 for activity log1.log2/.AdminMain: pid=761 uid=10022 gids={}
08-20 04:06:45.456: DEBUG/dalvikvm(753): LinearAlloc 0x0 used 637060 of 4194304 (15%)
08-20 04:06:49.026: DEBUG/dalvikvm(761): GC freed 3633 objects / 145376 bytes in 166ms
08-20 04:06:51.876: WARN/System.err(658): Can't dispatch DDM chunk 46454154: no handler defined
08-20 04:06:51.886: WARN/System.err(658): Can't dispatch DDM chunk 4d505251: no handler defined
08-20 04:06:51.895: INFO/jdwp(676): received file descriptor 27 from ADB
08-20 04:06:51.926: INFO/jdwp(687): received file descriptor 27 from ADB
08-20 04:06:55.227: WARN/ActivityManager(587): Launch timeout has expired, giving up wake lock!
08-20 04:06:55.757: WARN/ActivityManager(587): Activity idle timeout for HistoryRecord{4367c578 {log1.log2/log1.log2.AdminMain}}
08-20 04:06:56.206: DEBUG/dalvikvm(761): GC freed 3325 objects / 126264 bytes in 142ms
08-20 04:06:56.927: WARN/System.err(687): Can't dispatch DDM chunk 46454154: no handler defined
08-20 04:06:56.927: WARN/System.err(687): Can't dispatch DDM chunk 4d505251: no handler defined
08-20 04:06:56.957: WARN/System.err(676): Can't dispatch DDM chunk 46454154: no handler defined
08-20 04:06:56.957: WARN/System.err(676): Can't dispatch DDM chunk 4d505251: no handler defined
08-20 04:06:56.967: INFO/jdwp(692): received file descriptor 33 from ADB
08-20 04:06:57.026: INFO/jdwp(707): received file descriptor 25 from ADB
08-20 04:06:57.066: WARN/System.err(692): Can't dispatch DDM chunk 46454154: no handler defined
08-20 04:06:57.066: WARN/System.err(692): Can't dispatch DDM chunk 4d505251: no handler defined
08-20 04:07:04.906: WARN/System.err(707): Can't dispatch DDM chunk 46454154: no handler defined
08-20 04:07:04.936: WARN/System.err(707): Can't dispatch DDM chunk 4d505251: no handler defined
08-20 04:07:04.957: INFO/jdwp(761): received file descriptor 26 from ADB
08-20 04:07:05.546: DEBUG/dalvikvm(658): GC freed 2935 objects / 166312 bytes in 264ms
08-20 04:07:09.946: DEBUG/dalvikvm(761): GC freed 3289 objects / 117368 bytes in 170ms
08-20 04:07:10.607: DEBUG/dalvikvm(692): GC freed 3379 objects / 202040 bytes in 326ms
08-20 04:07:15.486: DEBUG/dalvikvm(633): GC freed 2236 objects / 120792 bytes in 205ms
08-20 04:07:16.897: WARN/System.err(761): Can't dispatch DDM chunk 46454154: no handler defined
08-20 04:07:16.897: WARN/System.err(761): Can't dispatch DDM chunk 4d505251: no handler defined
08-20 04:07:30.386: DEBUG/dalvikvm(761): GC freed 4161 objects / 124992 bytes in 184ms
08-20 04:07:35.147: WARN/WindowManager(587): No window to dispatch pointer action 0
08-20 04:07:35.246: WARN/WindowManager(587): No window to dispatch pointer action 1
08-20 04:07:35.346: WARN/WindowManager(587): No window to dispatch pointer action 0
08-20 04:07:35.466: WARN/WindowManager(587): No window to dispatch pointer action 1
08-20 04:07:35.707: WARN/WindowManager(587): No window to dispatch pointer action 0
08-20 04:07:35.827: WARN/WindowManager(587): No window to dispatch pointer action 1
Everytime when I click on the empty space, this error message will appear ;
08-20 04:07:35.707: WARN/WindowManager(587): No window to dispatch pointer action 0
08-20 04:07:35.827: WARN/WindowManager(587): No window to dispatch pointer action 1
Thank you so much for taking your time reading this! I appreciate it!!
-Dayne