80,350
社区成员
发帖
与我相关
我的任务
分享
Cursor cursor = database.rawQuery (
"SELECT * FROM tops WHERE schulteLevel=3", null);
cursor = database.rawQuery (
"SELECT * FROM tops order by completeTime asc", null);
cursor = database.rawQuery ("SELECT * FROM tops limit 0, 5", null);
感谢上面的回答,我是这么写的,为什么还会显示schulteLevel = 4、5、6... 的项?private void init ()
{
Intent intent = getIntent ();
m_nCompleteTime = intent.getIntExtra (
AppConst.IntentDataKey.SCHULTE_COMPLETE_TIME, 0);
m_nSchulteSize = intent.getIntExtra (
AppConst.IntentDataKey.SCHULTE_SIZE, 0);
m_strCurrentDate = intent
.getStringExtra (AppConst.IntentDataKey.SCHULTE_COMPLETE_CURRENT_DATE);
m_strCompleteTime = String.valueOf (m_nCompleteTime);
m_lvSchulteRanking = (ListView)findViewById (R.id.lvSchulteRanking);
SimpleAdapter simpleAdapter = new SimpleAdapter (
getApplicationContext (), getData (),
R.layout.activity_schulte_ranking_item, new String[]{
"currentDate", "completeTime"}, new int[]{
R.id.tvSchulteRankingCurrentDate,
R.id.tvSchulteRankingCompleteTime});
m_lvSchulteRanking.setAdapter (simpleAdapter);
}
private List<Map<String, Object>> getData ()
{
List<Map<String, Object>> list = new ArrayList<Map<String, Object>> ();
DatabaseHelper helper = new DatabaseHelper (m_Context,
DatabaseHelper.DATABASE_NAME, null,
DatabaseHelper.DATABASE_VERSION);
SQLiteDatabase database = helper.getWritableDatabase ();
Cursor cursor = database.rawQuery (
"select * from tops order by completeTime asc", null);
if (cursor.getCount () > 0)
{
for (cursor.moveToFirst (); !(cursor.isAfterLast ()); cursor
.moveToNext ())
{
Map<String, Object> map = new HashMap<String, Object> ();
m_strCurrentDate = cursor.getString (cursor
.getColumnIndex ("currentDate"));
m_strCompleteTime = cursor.getString (cursor
.getColumnIndex ("completeTime"));
map.put ("currentDate", m_strCurrentDate);
map.put ("completeTime", m_strCompleteTime);
list.add (map);
}
}
return list;
}
根据取到的m_nSchulteSize来判断显示不同的排行榜