如何在android中隐藏光标的特定行

发布于 2024-08-29 20:35:53 字数 152 浏览 1 评论 0原文

我有一个光标,它有 40 行,我想在用户选中复选框时隐藏一些行。

一种方法是在游标上再次运行查询,但这对我没有帮助,因为条件是由Java完成的(计算余额,有很多逻辑)。

我需要一些东西来获取当前行,并返回它是否可以显示。

任何帮助将不胜感激。

I have a cursor, and it got, lets say, 40 rows, I want to hide some rows when the user check a checkbox.

one way is run the query again on the cursor, but it doesn't help me because the condition is done by Java (calculate balance, with many logic).

I need something that will get the current row, and return if it can be show or not.

any help will be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白鸥掠海 2024-09-05 20:35:54

我继承了 CursorWrapper 并重写了一些方法,这里是代码:

public class SelectableCursorWrapper extends CursorWrapper {

private HashSet<Integer> mWhichShow;

public SelectableCursorWrapper(Cursor cursor, HashSet<Integer> whichToShow) {
    super(cursor);

    mWhichShow = whichToShow;
}

@Override
public int getCount() {
    return mWhichShow.size();
}

@Override
public boolean moveToPosition(int position) {
    if (position >= super.getCount()) {
        return false;
    }

    if (mWhichShow.contains(position)) {
        return super.moveToPosition(position);
    } else {
        // Recursion on this method to move to the next element properly
        return this.moveToPosition(position + 1);
    }
}
}

感谢任何试图提供帮助的人!

i inherit CursorWrapper and override some of the methods, here is the code:

public class SelectableCursorWrapper extends CursorWrapper {

private HashSet<Integer> mWhichShow;

public SelectableCursorWrapper(Cursor cursor, HashSet<Integer> whichToShow) {
    super(cursor);

    mWhichShow = whichToShow;
}

@Override
public int getCount() {
    return mWhichShow.size();
}

@Override
public boolean moveToPosition(int position) {
    if (position >= super.getCount()) {
        return false;
    }

    if (mWhichShow.contains(position)) {
        return super.moveToPosition(position);
    } else {
        // Recursion on this method to move to the next element properly
        return this.moveToPosition(position + 1);
    }
}
}

thanks for anyone that try to help!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文