Android 如何在列表视图中仅显示数据库中的部分数据
下面是我将数据从db检索到listview的代码Android 如何在列表视图中仅显示数据库中的部分数据,android,database,listview,simplecursoradapter,Android,Database,Listview,Simplecursoradapter,下面是我将数据从db检索到listview的代码 private void fillData() { Cursor c = viewDB.fetchAllRows(); startManagingCursor(c); String[] from = new String[] { ViewComplaintsDataDB.KEY_NUMBER, ViewComplaintsDataDB.KEY_DESCRIPTION, V
private void fillData() {
Cursor c = viewDB.fetchAllRows();
startManagingCursor(c);
String[] from = new String[] { ViewComplaintsDataDB.KEY_NUMBER,
ViewComplaintsDataDB.KEY_DESCRIPTION,
ViewComplaintsDataDB.KEY_LOGGEDBY }; //these three are the fields in my db
int[] to = new int[] { R.id.com_num, R.id.com_desc , R.id.user }; //these three are the textview id's in my listitem.xml file
SimpleCursorAdapter simple = new SimpleCursorAdapter(this,
R.layout.listitem, c, from, to);
setListAdapter(simple);
}
这是有效的
我的数据库中第二列下的每行中都有大量数据。如何仅显示从第二个字段到listview的50个字符的数据。请帮助我。为此,您需要
ArrayAdapter
而不是SimpleCursorAdapter
,并从DB
获取显示所需的数据并将其设置为适配器……您只需将文本视图中的maxLength atribute设置为50即可
我想为超过50个字符的文本添加三个点(…)。如何追加?我不确定,但这可能与电话有关。我在模拟器中没有三个点,所以每个手机都可以用自己的方式处理。