在 ListView 中显示数据库时出错

发布于 2024-12-01 09:10:55 字数 5602 浏览 2 评论 0原文

我正在 ListView 中显示我的数据库。我使用名为 find geopointButton 来显示数据库。当我点击它时,应用程序崩溃了。这是堆栈跟踪:

08-25 17:03:11.308: ERROR/AndroidRuntime(8373): Uncaught handler: thread main exiting due to uncaught exception
08-25 17:03:11.338: ERROR/AndroidRuntime(8373): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cortes/com.cortes.Display}: java.lang.IllegalStateException: get field slot from row 1 col -1 failed
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at android.os.Looper.loop(Looper.java:123)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at android.app.ActivityThread.main(ActivityThread.java:4363)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at java.lang.reflect.Method.invokeNative(Native Method)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at java.lang.reflect.Method.invoke(Method.java:521)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at dalvik.system.NativeStart.main(Native Method)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373): Caused by: java.lang.IllegalStateException: get field slot from row 1 col -1 failed
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at android.database.CursorWindow.getString_native(Native Method)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at android.database.CursorWindow.getString(CursorWindow.java:363)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:49)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at com.cortes.Display.onCreate(Display.java:116)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     ... 11 more

这是我的代码:

c = db.query(Geo_Create_Table, new String[ {"_id","latitude","longitude","address"}, null,null, null, null, null);

x1 = c.getColumnIndex("_id");
y1 = c.getColumnIndex("latitude");
z1 = c.getColumnIndex("longiitude");
w1 = c.getColumnIndex("address");
while(c.moveToNext()) {
    a = c.getInt(x1);
    b1 = c.getString(y1);
    c1 = c.getString(z1);
    e = c.getString(w1);

    results.add(a+"" + " " + b1 + " " + c1 + " " + e); 
}
ArrayAdapter<String> a11=new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, results);
lv.setAdapter(a11); 

这是我的 AndroidManifest.xml 文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.cortes"
    android:versionCode="1"
    android:versionName="1.0">

        <uses-sdk android:minSdkVersion="7" />
        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
        <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
        <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
        <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
        <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
        <uses-permission android:name="android.permission.INTERNET" />

        <application 
              android:icon="@drawable/icon" 
              android:label="@string/app_name">

              <uses-library 
                   android:required="true" 
                   android:name="com.google.android.maps"/>

              <activity 
                      android:name=".Cortes"
                      android:label="@string/app_name">
                      <intent-filter>
                          <action android:name="android.intent.action.MAIN" />
                          <category android:name="android.intent.category.LAUNCHER" />
                      </intent-filter>
              </activity>
              <activity 
                      android:name=".Display"
                      android:label="@string/app_name"
                      android:launchMode="singleTask">
                      <intent-filter>
                           <action android:name="android.intent.action.VIEW" />
                           <category android:name="android.intent.category.DEFAULT" />
                      </intent-filter>
               </activity>
        </application>
</manifest>

关于如何解决此问题有什么建议吗?

I am displaying my database in a ListView. I used a Button named find geopoint for displaying the database. when I click on it, the application crashes. Here is the stack trace:

08-25 17:03:11.308: ERROR/AndroidRuntime(8373): Uncaught handler: thread main exiting due to uncaught exception
08-25 17:03:11.338: ERROR/AndroidRuntime(8373): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cortes/com.cortes.Display}: java.lang.IllegalStateException: get field slot from row 1 col -1 failed
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at android.os.Looper.loop(Looper.java:123)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at android.app.ActivityThread.main(ActivityThread.java:4363)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at java.lang.reflect.Method.invokeNative(Native Method)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at java.lang.reflect.Method.invoke(Method.java:521)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at dalvik.system.NativeStart.main(Native Method)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373): Caused by: java.lang.IllegalStateException: get field slot from row 1 col -1 failed
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at android.database.CursorWindow.getString_native(Native Method)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at android.database.CursorWindow.getString(CursorWindow.java:363)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:49)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at com.cortes.Display.onCreate(Display.java:116)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
08-25 17:03:11.338: ERROR/AndroidRuntime(8373):     ... 11 more

Here is my code:

c = db.query(Geo_Create_Table, new String[ {"_id","latitude","longitude","address"}, null,null, null, null, null);

x1 = c.getColumnIndex("_id");
y1 = c.getColumnIndex("latitude");
z1 = c.getColumnIndex("longiitude");
w1 = c.getColumnIndex("address");
while(c.moveToNext()) {
    a = c.getInt(x1);
    b1 = c.getString(y1);
    c1 = c.getString(z1);
    e = c.getString(w1);

    results.add(a+"" + " " + b1 + " " + c1 + " " + e); 
}
ArrayAdapter<String> a11=new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, results);
lv.setAdapter(a11); 

Here is my AndroidManifest.xml file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.cortes"
    android:versionCode="1"
    android:versionName="1.0">

        <uses-sdk android:minSdkVersion="7" />
        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
        <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
        <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
        <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
        <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
        <uses-permission android:name="android.permission.INTERNET" />

        <application 
              android:icon="@drawable/icon" 
              android:label="@string/app_name">

              <uses-library 
                   android:required="true" 
                   android:name="com.google.android.maps"/>

              <activity 
                      android:name=".Cortes"
                      android:label="@string/app_name">
                      <intent-filter>
                          <action android:name="android.intent.action.MAIN" />
                          <category android:name="android.intent.category.LAUNCHER" />
                      </intent-filter>
              </activity>
              <activity 
                      android:name=".Display"
                      android:label="@string/app_name"
                      android:launchMode="singleTask">
                      <intent-filter>
                           <action android:name="android.intent.action.VIEW" />
                           <category android:name="android.intent.category.DEFAULT" />
                      </intent-filter>
               </activity>
        </application>
</manifest>

Any suggestions on how to solve this problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文