views:

55

answers:

1

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

A: 

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