我是安卓新手。我正在尝试编写一个方法,该方法将在 3 个不同的文本视图中显示来自数据库同一行的 3 个不同列。现在,我有 3 个相同的方法,每个方法显示同一行的不同列:
Display part of Method #1:
if (cursor != null){
cursor.moveToFirst();
result = result
+ cursor.getString(0);
return result;
}
return null;
Display part of Method #2:
if (cursor != null){
cursor.moveToFirst();
result = result
+ cursor.getString(1);
return result;
}
return null;
Display part of Method #3:
if (cursor != null){
cursor.moveToFirst();
result = result
+ cursor.getString(2);
return result;
}
return null;
所以我的问题是:有没有办法编写一个方法,其结果类似于“对于单个 DB 行,cursor.getString(0);在 TextView #1 中显示,cursor.getString(1);在TextView #2, cursor.getString(2); 在 TextView #3 中显示?”