上的ImageButton孩子Expandablelistview项目 [英] ImageButton on Expandablelistview child item

查看:110
本文介绍了上的ImageButton孩子Expandablelistview项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能对Expandablelistview子项目可点击的ImageButton?如果是,怎么它的事件侦听器程序?

Is it possible to have a clickable ImageButton on Expandablelistview child item? If yes, how to program its event listener?

推荐答案

在您的适配器,覆盖getChildView方法。为充气包含该按钮的子视图自定义布局。查找按钮查看和设置监听器。你可能想/需要重写一些其他适配器方法为好。

In your Adapter, override the getChildView method. Inflate a custom layout for the child view which contains the button. Find the button view and set the listener. You may want/need to override a few of the other Adapter methods as well.

@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
            View convertView, ViewGroup parent) {

        View v = mInflater.inflate(R.layout.expander_child, null);

        Button button = (Button)v.findViewById(R.id.expand_child_button);
        button.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Toast.makeText(ExpandableList1.this, "button pushed", Toast.LENGTH_SHORT).show();
            }
        });         
        return v;
    }

这篇关于上的ImageButton孩子Expandablelistview项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆