同一个 ExpandableListView 可以有多个 onClickListener 吗?

发布于 2024-11-09 17:23:40 字数 390 浏览 5 评论 0原文

我已经为我的自定义 ExpandableListView 成功设置了一个 onClickListener

elv.setOnChildClickListener(new OnChildClickListener() {
    public boolean onChildClick(ExpandableListView parent, View v, 
                                int groupPosition, int childPosition, long id) {
    }
);

我可以在同一个类中的某个地方也有一个 onGroupClickListener 吗?

I have an onClickListener sucessfully set up for my custom ExpandableListView

elv.setOnChildClickListener(new OnChildClickListener() {
    public boolean onChildClick(ExpandableListView parent, View v, 
                                int groupPosition, int childPosition, long id) {
    }
);

Can I have a onGroupClickListener somewhere in the same class too?

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

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

发布评论

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

评论(1

浅忆流年 2024-11-16 17:23:40

同一个 ExpandableListView 可以有多个 onClickListener 吗?

简短回答:不。

您可以:

  1. 让单子单击侦听器执行许多操作。

  2. 设计您自己的自定义侦听器系统来注册自定义侦听器。在自定义侦听器系统中注册自定义侦听器。让 ExpandableListView 的单子单击侦听器告诉自定义侦听器系统循环访问其所有侦听器并向它们通知该事件。

我可以在同一个类中的某个地方也有一个 onGroupClickListener 吗?

是的。您可以像为子单击侦听器所做的那样创建并注册一个侦听器。

Can I have multiple onClickListeners for the same expandableListView?

Short answer: No.

You could:

  1. Have the one child click listener do many things.

  2. Design your own custom listener system for registering custom listeners. Register custom listeners in your custom listener system. Have the one child click listener of the ExpandableListView tell the custom listener system to iterate through all of its listeners and notify them of the event.

Can I have a onGroupClickListener somewhere in the same class too?

Yes. You could create and register one very much like you did for the child click listener.

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