【问题标题】:ImageButton on Expandablelistview child itemExpandablelistview 子项上的 ImageButton
【发布时间】:2010-06-21 03:19:49
【问题描述】:

是否可以在 Expandablelistview 子项上有一个可点击的 ImageButton?如果是,如何编写它的事件监听器?

【问题讨论】:

    标签: android expandablelistview


    【解决方案1】:

    在您的适配器中,覆盖 getChildView 方法。为包含按钮的子视图膨胀自定义布局。找到按钮视图并设置监听器。您可能还需要/需要覆盖其他一些适配器方法。

    @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;
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-03-23
      • 1970-01-01
      • 1970-01-01
      • 2015-12-15
      • 2019-05-23
      • 2022-11-07
      • 2011-09-22
      • 1970-01-01
      相关资源
      最近更新 更多