Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/178.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 根据数据库值高亮显示ListView行_Java_Android_Listview - Fatal编程技术网

Java 根据数据库值高亮显示ListView行

Java 根据数据库值高亮显示ListView行,java,android,listview,Java,Android,Listview,我需要根据从填充ListView的数据集中提取的值高亮显示ListView行。如下面的代码所示,我知道如何通过视图绑定器基于数据库值修改textview。是否有方法从视图活页夹更新行?据我所知,我只能从视图绑定器更新文本字段,而不能更新父行属性 我目前正在使用SimpleCorsorAdapter,但怀疑需要创建某种类型的自定义适配器。但是,一旦进入自定义适配器,我就无法访问db游标来读取字段以确定是否高亮显示该行,可以吗 我只是想澄清一下,我并不是想在选中行时突出显示它;我知道怎么做。我也不想

我需要根据从填充ListView的数据集中提取的值高亮显示ListView行。如下面的代码所示,我知道如何通过视图绑定器基于数据库值修改textview。是否有方法从视图活页夹更新行?据我所知,我只能从视图绑定器更新文本字段,而不能更新父行属性

我目前正在使用SimpleCorsorAdapter,但怀疑需要创建某种类型的自定义适配器。但是,一旦进入自定义适配器,我就无法访问db游标来读取字段以确定是否高亮显示该行,可以吗

我只是想澄清一下,我并不是想在选中行时突出显示它;我知道怎么做。我也不想只突出显示一个textview——我试图突出显示整个listView行(或者至少是我的R.layout.stream XML文件中的一个LinearLayout)

我在数据库记录中有一个布尔值,指示是否突出显示该行。感谢您提供的任何输入

以下是我主要活动的一部分:

    cursor = db.query(DbHelper.TABLE, null, null, null, null, null, DbHelper.C_TIMESTAMP + " DESC", null);
    startManagingCursor(cursor);

    adapter = new SimpleCursorAdapter(this, R.layout.stream, cursor, FROM, TO);

    adapter.setViewBinder(VIEW_BINDER);

    listStream.setAdapter(adapter); 
 ...
这是视图活页夹的一部分:

 static final ViewBinder VIEW_BINDER = new ViewBinder() {

    public boolean setViewValue(View view, Cursor cursor, int columnIndex) {

        if (view.getId() == R.id.textTimestamp) {


            String postDate = cursor.getString(columnIndex);    

            ((TextView) view).setText(tHandler.getRelativeLocalTime(view.getContext(),postDate));

            return true;
 ...
活动XML布局文件的相关部分:

    <ListView
        android:layout_height="fill_parent"
        android:layout_width="fill_parent"
        android:id="@+id/listStream"
        android:background="@color/lightGreen"
        android:layout_below="@+id/streamHeader">           
    </ListView>


您有解决方案吗?您有解决方案吗?