ListView with CHOICE_MODE_MULTIPLE using CheckedText in a custom view

前端 未结 1 1959
谎友^
谎友^ 2020-11-30 01:42

There are plenty of questions of how to use CheckedTextView but I can\'t make it work correctly.

I have a CursorAdapter with a custom view

相关标签:
1条回答
  • 2020-11-30 02:01

    Based on my read of the code, the row has to implement Checkable:

    if (mChoiceMode != CHOICE_MODE_NONE && mCheckStates != null) {
        if (child instanceof Checkable) {
            ((Checkable) child).setChecked(mCheckStates.get(position));
        }
    }
    

    This works for the stock row layouts for lists with choice mode because the row is a CheckedTextView, which implements Checkable.

    So, add the Checkable interface to your custom View, delegating the interface's methods to the CheckedTextView, and see if that works out.

    0 讨论(0)
提交回复
热议问题