Changing values from Cursor using SimpleCursorAdapter

后端 未结 5 1594
半阙折子戏
半阙折子戏 2020-12-01 03:50

I have database table with the columns {Name, Time (UTC format) , Latitude, Longitude}

I display the table using a ListActivity with a SimpleCursorAdapter.

I

5条回答
  •  情书的邮戳
    2020-12-01 04:28

    i also had the same problem after long struggle finally i found answer :) ( see below )

    use setViewText (TextView v, String text)
    

    for example

    SimpleCursorAdapter shows = new SimpleCursorAdapter(this, R.layout.somelayout, accountCursor, from, to)
    {
     @Override
     public void setViewText(TextView v, String text) {
     super.setViewText(v, convText(v, text));
    }    
    };
    
    private String convText(TextView v, String text)
    {
    
     switch (v.getId())
     {
     case R.id.date:
                 String formatedText = text;
                 //do format
                return formatedText;
            }
    return text;
    }
    

提交回复
热议问题