开发者

Android: How to make child rows in ExpandableListView non-cklickable?

Guess this is pretty simple, but searching didn't help...

I want an ExpandableListView, where you can not select the child rows.

I tried to set the selector to "transparent", but it still changed the text color, so you would no开发者_如何学Ctice that you've clicked.

Kind regards, jellyfish


If you too late, but I hope it helps someone.

You must implement this method in your adapter:

public class MyExpandableAdapter extends BaseExpandableListAdapter {
    @Override
    public boolean isChildSelectable(int arg0, int arg1) {
        // Al childs items, If you want some active items have to specify their indices and return true or false
        return false;
    }
    // With all other methods
    ...
}


have you tried to add the setFocusable(false) param on the child views? also change the text color to black. the default has a selector black default to white pressed. so basically change every color of the child view to a non selectable one.


I realized that in most Android apps (e.g. the settings on my own phone) apparently nobody bothers to switch off the "click" animation even if there is no action afterwards. Therefore I decided to just leave it this way, too.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜