我尝试自定义 SimpleCursorAdapter 来解码一个值并设置为 textview 但不工作
我的自定义 simplecursoraapter 类:
public class simpledecode extends SimpleCursorAdapter{
private NotesDbAdapter mDbHelper;
public simpledecode(Context context, int layout, Cursor c, String[] from,
int[] to) {
super(context, layout, c, from, to);
}
@Override
public void setViewText(TextView v, String text) {
// TODO Auto-generated method stub
super.setViewText(v, text);
v.setText(mDbHelper.base64toString(text));
}
我的解码方法:
public String base64toString(String text)
{
byte[] data1 = Base64.decode(text, Base64.DEFAULT);
String text1 = null;
try {
return text1 = new String(data1, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return null;
}
}