如何区分在Android的ListView的读和未读邮件? [英] How to differentiate read and unread messages in android ListView?

查看:110
本文介绍了如何区分在Android的ListView的读和未读邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SimpleCursorAdapter 用在我的code。 光标包含字段(真/假)。 如果这是真的,那么行应显示为灰色文本颜色,如果误 - 白色

SimpleCursorAdapter is used in my code. Cursor contains field read (true/false). If it is true, then row should be shown with grey text color, if false - with white.

推荐答案

如果它是为你写,你可以使用setViewBinder / setViewValue在SimpleCursorAdapter一样容易。以下将显示,获得真实漆成红色行布局一个TextView如果你的光标列保存你感兴趣的一些价值。如果有更多的领域,你需要应用一些小的改动。如果设置自己的价值观,返回false,如果Android的应该绘制返回true:

If it's as easy as that you've written you can use setViewBinder/setViewValue in your SimpleCursorAdapter. The following will show a TextView of the row-layout that get's painted in red if a column in your cursor holds some value of interest to you. If there are more fields you need to apply some minor changes. return true if you set own values, return false if Android should paint:

... create SimpleCursorAdapter
if (simpleCursorAdapter != null) {
  simpleCursorAdapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() {

    @Override
    public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
      TextView textView = (TextView) view;

      long l = cursor.getLong(positionOfReadValue);
      if (l == valueOfRead) {
        textView.setTextColor(Color.RED);
      }

      return false;
    }

  } );

  setListAdapter(simpleCursorAdapter);
}
...

这篇关于如何区分在Android的ListView的读和未读邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆