Android SimpleAdapter显示问题
2013-11-09 19:17
459 查看
当用户第一次点击软件时,第一个版本只是显示记录的标题,没有显示记录的日期,所以应该加上去?
解决方案:
原来在MainShow.java代码如下:
while (c.moveToNext()) {
Map<String, Object> map = new HashMap<String, Object>();
String strTime=c.getString(c.getColumnIndex("noteTime"));
map.put("noteTime", strTime);
String strName = c.getString(c.getColumnIndex("noteName"));
// 如果标题内容超过16个字节,则截取前6个字节+“...”
if (strName.length() > 26) {
map.put("noteName", strName.substring(0, 26));
} else {
map.put("noteName", strName);
}
map.put("noteId", c.getInt(c.getColumnIndex("noteId")));
list.add(map);
}
c.close();
sdb.close();
if (count > 0) {
// 这里加载R.layout.items列表项布局文件
sa = new SimpleAdapter(MainShow.this, list, R.layout.items,
new String[] { "noteName", "noteTime" }, new int[] {
R.id.noteName, R.id.noteTime });
lv.setAdapter(sa);
}
但经过导入到手机上,证明只能显示记录的标题,无法显示时间。
解决方案是:
把记录的时间加到记录标题的后面,连接成一个字段,修改代码如下:
while (c.moveToNext()) {
Map<String, Object> map = new HashMap<String, Object>();
String strTime=c.getString(c.getColumnIndex("noteTime"));
map.put("noteTime", strTime);
String strName = c.getString(c.getColumnIndex("noteName"));
// 如果标题内容超过16个字节,则截取前6个字节+“...”
if (strName.length() > 26) {
map.put("noteName", strName.substring(0, 26)+strTime);
} else {
map.put("noteName", strName+strTime);
}
map.put("noteId", c.getInt(c.getColumnIndex("noteId")));
list.add(map);
}
c.close();
sdb.close();
if (count > 0) {
// 这里加载R.layout.items列表项布局文件
sa = new SimpleAdapter(MainShow.this, list, R.layout.items,
new String[] { "noteName", "noteTime" }, new int[] {
R.id.noteName, R.id.noteTime });
lv.setAdapter(sa);
}
再次运行,可以显示标题和时间。
解决方案:
原来在MainShow.java代码如下:
while (c.moveToNext()) {
Map<String, Object> map = new HashMap<String, Object>();
String strTime=c.getString(c.getColumnIndex("noteTime"));
map.put("noteTime", strTime);
String strName = c.getString(c.getColumnIndex("noteName"));
// 如果标题内容超过16个字节,则截取前6个字节+“...”
if (strName.length() > 26) {
map.put("noteName", strName.substring(0, 26));
} else {
map.put("noteName", strName);
}
map.put("noteId", c.getInt(c.getColumnIndex("noteId")));
list.add(map);
}
c.close();
sdb.close();
if (count > 0) {
// 这里加载R.layout.items列表项布局文件
sa = new SimpleAdapter(MainShow.this, list, R.layout.items,
new String[] { "noteName", "noteTime" }, new int[] {
R.id.noteName, R.id.noteTime });
lv.setAdapter(sa);
}
但经过导入到手机上,证明只能显示记录的标题,无法显示时间。
解决方案是:
把记录的时间加到记录标题的后面,连接成一个字段,修改代码如下:
while (c.moveToNext()) {
Map<String, Object> map = new HashMap<String, Object>();
String strTime=c.getString(c.getColumnIndex("noteTime"));
map.put("noteTime", strTime);
String strName = c.getString(c.getColumnIndex("noteName"));
// 如果标题内容超过16个字节,则截取前6个字节+“...”
if (strName.length() > 26) {
map.put("noteName", strName.substring(0, 26)+strTime);
} else {
map.put("noteName", strName+strTime);
}
map.put("noteId", c.getInt(c.getColumnIndex("noteId")));
list.add(map);
}
c.close();
sdb.close();
if (count > 0) {
// 这里加载R.layout.items列表项布局文件
sa = new SimpleAdapter(MainShow.this, list, R.layout.items,
new String[] { "noteName", "noteTime" }, new int[] {
R.id.noteName, R.id.noteTime });
lv.setAdapter(sa);
}
再次运行,可以显示标题和时间。
相关文章推荐
- Android SimpleAdapter显示ListView、GridView
- android 使用SimpleCursorAdapter将SQLite数据显示到ListView
- Android 解决ListView、GridView在首次显示时adapter可能多次调用getView的问题
- Adnroid开发中ListView使用SimpleAdapter显示复杂列表的问题
- 学习Android之SimpleAdapter显示网络图片
- Android SimpleAdapter显示ListView、GridView
- 解决Android开发中ViewPager动态设置PagerAdapter时第二次进入Fragment内容不显示的问题
- Android SimpleAdapter显示ListView、GridView
- Android SimpleAdapter显示ListView、GridView
- android 从activity用intent跳转到listactivity并在其中用simpleadapter在listview中显示数据列
- Android SimpleAdapter 的list刷新问题。
- android中SimpleCursorAdapter _id错误的问题
- Android中使用ListView显示列表之SimpleAdapter的使用
- Android SimpleAdapter 的list刷新问题。
- 【Android基础】listview控件的使用(3)------Map与SimpleAdapter组成的多显示条目的Listview
- Android SimpleAdapter显示ListView、GridView
- Android SimpleAdapter显示ListView、GridView
- android 中关于SimpleAdapter构造参数的问题
- 使用android.widget.SimpleAdapter.ViewBinder的一点问题!
- 【Android基础】listview控件的使用(3)------Map与SimpleAdapter组成的多显示条目的Listview