我在SQLiteDatabase中存储了一个通话时间(以秒为单位),我需要以分钟形式显示给用户。这里是语句:Android:在显示前对Cursor中的SQL返回值执行算术运算
Cursor listCur = mDb.rawQuery(
"SELECT * FROM " + mDbCallTable.TABLE_NAME +
" JOIN " + mDbPhoneTable.TABLE_NAME +
" ON " + mDbCallTable.TABLE_NAME+"."+mDbCallTable.COLUMN_PHONE+"="+mDbPhoneTable.TABLE_NAME+"."+mDbPhoneTable.COLUMN_PHONE +
" JOIN " + mDbCustomerTable.TABLE_NAME +
" ON " + mDbPhoneTable.TABLE_NAME+"."+mDbPhoneTable.COLUMN_CUST_ID+"="+mDbCustomerTable.TABLE_NAME+"."+mDbCustomerTable._ID,
null
);
这里是我把它连接到SimpleCursorAdapter显示:
ListView theList;
SimpleCursorAdapter adapter;
theList = (ListView)findViewById(R.id.call_list);
listCur.moveToFirst();
adapter = new SimpleCursorAdapter(
MainActivity.this,
R.layout.call_list_item,
listCur,
new String[] {
mDbCallTable.TABLE_NAME+"."+mDbCallTable.COLUMN_PHONE,
mDbCustomerTable.TABLE_NAME+"."+mDbCustomerTable.COLUMN_NAME,
mDbCallTable.TABLE_NAME+"."+mDbCallTable.COLUMN_DURATION
},
new int[] {
R.id.item_text_phone,
R.id.item_text_customer,
R.id.item_text_duration
}
);
theList.setAdapter(adapter);
地方在这里,我需要60分拿到分钟加1(四舍五入最近的分钟)。我该怎么做呢?
这完全做的工作。谢谢。 – moonlightcheese 2011-03-15 21:21:57