有时SimpleCursorAdapter列'_id'不存在,并不总是存在。为什么呢?

时间:2016-03-27 03:24:21

标签: android simplecursoradapter

我使用SimpleCursorAdapter向ListView显示信息。

adapter = new SimpleCursorAdapter(
                this,
                R.layout.item_music,
                myCursor,
                new String[]{
                        MediaStore.Audio.Media.ARTIST,
                        MediaStore.Audio.Media.ALBUM,
                        MediaStore.Audio.Media.TITLE,
                        MediaStore.Audio.Media._ID},
                // To widget ids in the row layout...
                new int[]{
                        R.id.item_artist,
                        R.id.item_album,
                        R.id.item_title,
                        R.id.item_action});

它有时会起作用,有时会因错误“列'_id'不存在而崩溃”。发生了什么事?

这是我的Logcat:

java.lang.IllegalArgumentException: column '_id' does not exist
at android.database.AbstractCursor.getColumnIndexOrThrow(AbstractCursor.java:303)
at android.support.v4.widget.CursorAdapter.swapCursor(CursorAdapter.java:344)
at android.support.v4.widget.SimpleCursorAdapter.swapCursor(SimpleCursorAdapter.java:326)

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

每当您想要从angular.module('demo') .controller('democtrl', ['$scope', function ($scope) { $scope.selectedOption = "ip"; }]); 中选择内容并显示到select _id时,您需要database

例如:

listView