为 ExpandableListView 设置 onChildClickListener 时出现问题
我在让可扩展列表视图的点击侦听器正常工作时遇到问题。我是否正确执行此操作?
代码:
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;
}
});
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;
}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您尚未在 Toast 消息中调用 show()。因此,如果您确定它是否仅适用于 Toast 消息,那么它似乎不起作用。添加.show();在创建吐司的行的末尾,它应该显示
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