Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/178.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java ListView ArrayAdapter未显示正确的数据_Java_Android_Sqlite - Fatal编程技术网

Java ListView ArrayAdapter未显示正确的数据

Java ListView ArrayAdapter未显示正确的数据,java,android,sqlite,Java,Android,Sqlite,我让它工作,以便在listview中显示从数据库检索到的一些数据。它显示my db中的10行,而my db只有10行,但问题是,它显示为com.example.somename。LocationData@23157b39. 为什么会出现这种情况?我如何解决?所以问题出在LocationHistory.java活动中。它在我的显示器上显示奇怪的包名 活动\位置\历史记录.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayo

我让它工作,以便在listview中显示从数据库检索到的一些数据。它显示my db中的10行,而my db只有10行,但问题是,它显示为com.example.somename。LocationData@23157b39. 为什么会出现这种情况?我如何解决?所以问题出在LocationHistory.java活动中。它在我的显示器上显示奇怪的包名

活动\位置\历史记录.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    tools:context=".LocationHistory">

    <ListView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@android:id/list"
        android:layout_gravity="center_horizontal" />
</LinearLayout>
日志:

09-18 00:16:12.614  25181-25181/com.example.somename I/EXPLORECA﹕ COLUMN_ID 1
09-18 00:16:12.614  25181-25181/com. example.somename I/EXPLORECA﹕ COLUMN_LATITUDE  21.36654189
09-18 00:16:12.614  25181-25181/com. example.somename I/EXPLORECA﹕ COLUMN_LONGITUDE 6.945669
09-18 00:16:12.614  25181-25181/com. example.somename I/EXPLORECA﹕ COLUMN_TIME 12:10:34 AM
09-18 00:16:12.614  25181-25181/com. example.somename I/EXPLORECA﹕ locationdata com. example.somename.LocationData@1b6b10f7
09-18 00:16:12.614  25181-25181/com. example.somename I/EXPLORECA﹕ locations [com. example.somename.LocationData@1b6b10f7]

我想,问题就在这里

Log.iLOGTAG,位置数据+位置数据

实际上称为Log.iLOGTAG,locationdata+locationdata.toString。但是LocationData.toString方法在调用时未实现和使用Object.toString

 Log.i(LOGTAG, "locationdata " + locationdata);
实际上,您正在尝试将List locationdata List转换为String,您可以对primivive类型执行此操作,但如果您想在类中执行此操作,则必须提供自己的toString实现

请加上

 @Override
 public String toString() {
    return this.getId();
 }
然后再试一次


祝你好运

嘿,谢谢你的回复。日志。我把它放在那里之后,我的活动显示了那些奇怪的包名。我把它放在那里是为了看看他们是否能显示出任何好的数据。所以没有日志。我的,它仍然显示活动中那些奇怪的包名。嘿,谢谢你的回复。日志。我把它放在那里之后,我的活动显示了那些奇怪的包名。我把它放在那里是为了看看他们是否能显示出任何好的数据。因此,在没有Log.i的情况下,它仍然会在活动中显示那些奇怪的包名。
09-18 00:16:12.614  25181-25181/com.example.somename I/EXPLORECA﹕ COLUMN_ID 1
09-18 00:16:12.614  25181-25181/com. example.somename I/EXPLORECA﹕ COLUMN_LATITUDE  21.36654189
09-18 00:16:12.614  25181-25181/com. example.somename I/EXPLORECA﹕ COLUMN_LONGITUDE 6.945669
09-18 00:16:12.614  25181-25181/com. example.somename I/EXPLORECA﹕ COLUMN_TIME 12:10:34 AM
09-18 00:16:12.614  25181-25181/com. example.somename I/EXPLORECA﹕ locationdata com. example.somename.LocationData@1b6b10f7
09-18 00:16:12.614  25181-25181/com. example.somename I/EXPLORECA﹕ locations [com. example.somename.LocationData@1b6b10f7]
 Log.i(LOGTAG, "locationdata " + locationdata);
 @Override
 public String toString() {
    return this.getId();
 }