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();开发者_C百科
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;
}
});
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
精彩评论