有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java SimpleCursorAdapter删除值

我在每一行都有一个ListView,我有一个LinearLayout,其中有一些对象(主要是一些文本视图)

我用光标动态填充这个列表视图。在这个游标中,我有一个值true或false

我想隐藏或使值为false的行不可单击。我尝试了这个代码,但不起作用

public void contentProviderInitialized(final Cursor cursor) {

    SimpleCursorAdapter commonTickets = new SimpleCursorAdapter(MyClass.this,
        R.layout.row_ticketing, cursor, new String[] {"price", "productName", "stopName" },
        new int[] { R.id.ticketing_price, R.id.ticketing_product, R.id.ticketing_stop_name }
    ) {
        @Override
        public void bindView(View view, Context context, Cursor cursor) {
            String enabledStr = cursor.getString(cursor.getColumnIndex("enabled"));
            String product = cursor.getString(cursor.getColumnIndex("productName"));
            boolean enabled = Boolean.parseBoolean(enabledStr);
            LinearLayout ticketingRow = (LinearLayout) view.findViewById(R.id.ticketing_row);
            if (enabled) {
                ticketingRow.setEnabled(true);
            } else {
                ticketingRow.setEnabled(false);
            }
            super.bindView(view, context, cursor);
        };
        MyClass.this.ticketing_list_view.setAdapter(commonTickets);
    }
}

共 (2) 个答案