Androids ExpandableListView - where to put the button listener for buttons that are children


Staff member
I have been playing around a lot with the ExpandableListView and I cannot figure out where to add the button listeners for the button that will be the children in the view. I did manage to get a button listener working that uses getChildView() below, but it seems to be the same listener for all the buttons.

The best case scenario is that I would be able to implement the button listeners in the class that instantiates the ExpandableListAdapter class, and not have to put the listeners in the actual ExpandableListAdapter class. At this point I don't even know if that is possible

I have been experimenting with this tutorial/code: <a href="" rel="nofollow">HERE</a>


public View getChildView(int set_new, int child_position, boolean view, View view1, ViewGroup view_group1)
    ChildHolder childHolder;
    if (view1 == null)

        view1 = LayoutInflater.from(info_context).inflate(R.layout.list_group_item_lv, null);

        childHolder = new ChildHolder();

        childHolder.section_btn = (Button)view1.findViewById(;
        childHolder.section_btn.setOnClickListener(new OnClickListener()

            public void onClick(View v)
                Toast.makeText(info_context, "button pushed", Toast.LENGTH_SHORT).show();


    }else {
        childHolder = (ChildHolder) view1.getTag();
        Typeface tf = Typeface.createFromAsset(info_context.getAssets(), "fonts/AGENCYR.TTF");

        return view1;

Any help would be much appreciated. Thank you and I will be standing by.