我有一个应用程序,我可以在其中创建一些课程(英语、法语、...)。这些课程有一个开始和结束日期。我将选定的日期作为字符串存储在我的数据库中。
我想知道创建一个带有 3 个选项卡(过去/当前/未来)的 TabbedActivity。
Past 将包含日期结束在当前日期之前的所有课程。Current 将包含当前日期在 2 个日期的开始和结束之间的所有课程。Futur 将包含开始日期在当前日期之后的所有课程。
但是,由于我将它们存储为字符串值,这可能吗?如果是,你能解释一下怎么做吗?
如果您需要,我可以发布一些代码(我现在不发布代码,因为如果可能的话,我要问的是什么)。
感谢你们!
@update 使用助手中的方法
public Cursor getCoursFuture()
{
Calendar c = Calendar.getInstance();
DateFormat df = new SimpleDateFormat("dd-MM-yyyy");
Date date = c.getTime();
String currentDate = df.format(date);
String query ="select ID as _id, branche_cours, designation from "+TABLE_COURS+" where date('"+COLONNE_DATEPREMIER+"') > '"+currentDate+"'";
Open();
Cursor cursor = db.rawQuery(query,null);
return cursor;
}
我的 SimpleCursorAdapter
lvCours =(ListView)findViewById(R.id.ListCours);
final Cursor cursor = dbhelper.getCoursFuture();
String[] from = { "branche_cours", "designation" };
int[] to = { R.id.text_branche_cours, R.id.text_designation };
lvCours.setAdapter(adapter);
adapter = new SimpleCursorAdapter(this, R.layout.list_row, cursor, from, to, 0);
lvCours.setAdapter(adapter);
adapter.notifyDataSetChanged();