在我的App
中,我试图将学生的分数保存在中SQLite Table
,并显示在中ListView
,我App
还具有SORT
命令功能,当我分别输入学生 89、78、90、100 的分数时,我想对 List
分数进行排序100分的学生姓名升序排在最前面,然后是78分、89分、90分的学生,依次出现在列表中,为什么会出现这个bug?我的数据库架构是:
public static final String COL_ID = "_id";
public static final String COL_NAME = "name";
public static final String COL_ADDRESS = "address";
public static final String COL_MARKS = "marks";
protected static final String CREATE_QUERY = "CREATE TABLE " + FRIEND_TABLE +
" (" + COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
COL_NAME + " TEXT, " + COL_ADDRESS + " TEXT," +
COL_MARKS + " TEXT)";
排序逻辑PrefrenceActivity
如下所示:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<ListPreference
android:dialogTitle="Choose a sort order"
android:key="sort_order"
android:summary="Choose your preferred sort order"
android:title="Sort Order"
android:entries="@array/sort_names"
android:entryValues="@array/sort_clauses"/>
</PreferenceScreen>
数组是:
<string-array name="sort_names">
<item>By Name, Ascending</item>
<item>By Name, Descending</item>
<item>By Roll</item>
<item>By Address, Ascending</item>
<item>By Address, Descending</item>
</string-array>
<string-array name="sort_clauses">
<item>name ASC</item>
<item>name DESC</item>
<item>marks ASC</item>
<item>address ASC</item>
<item>address DESC</item>
</string-array>
任何人都可以找到这个提到的错误的解决方案!