开发者

Problem setting onChildClickListener for an ExpandableListView

开发者 https://www.devze.com 2023-03-15 22:27 出处:网络
I am having a problem getting my click listener for the expandable list view to work. Am I implementing this correctly?

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号