Cody
Cody

Reputation: 8944

Problem setting onChildClickListener for an ExpandableListView

I am having a problem getting my click listener for the expandable list view to work. Am I implementing this correctly?

Code:

elv = getExpandableListView();

// Set up the adapter
mAdapter = new MyExpandableListAdapter();
elv.setAdapter(mAdapter);

elv.setOnChildClickListener(new OnChildClickListener() {

        public boolean onChildClick(ExpandableListView parent, View v,
                int groupPosition, int childPosition, long id) {
            Toast.makeText(getApplicationContext(), "click", Toast.LENGTH_SHORT);
            v.setBackgroundColor(0x000000);
            return false;
        }
    });

Upvotes: 2

Views: 1673

Answers (1)

dymmeh
dymmeh

Reputation: 22306

You haven't called show() on your Toast message. So, if you're determining if it worked merely on the Toast message, it won't seem to be working. Add .show(); at the end of the line where you create the toast and it should show up

Upvotes: 4

Related Questions