开发者

Android: replace values of a cursor/sql query

In my SQL database table there are colums _id, int dayofweek, String text ... I now, do a SQL query on that table to get a cursor to the results. The results then are shown in 开发者_开发知识库a listView:

private void showBlocks()
{
    Cursor blocks = ttDB.getBlocks();
    startManagingCursor(blocks);

    int[] key = new int []{
            android.R.id.text1,
            android.R.id.text2 
    };

    SimpleCursorAdapter blockAdapter = new SimpleCursorAdapter(
            this, 
            android.R.layout.simple_list_item_2,
            blocks, 
            new String[] {
                    "day",
                    "text"
                }, 
            key);

    lv1.setAdapter(blockAdapter);
 }

How (and where) can I now replace the integer values of dayofweek by the corresponding strings? I thought about joining two tables while querying but then it will not be multilingual any more.


You can try using a ViewBinder via setViewBinder() on your SimpleCursorAdapter.

Or, extend SimpleCursorAdapter, override bindView() and do it yourself.


you can not directly replace values .you have to store first it in list and than you can replace it with ur desired fromat

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜