是否可以在 Expandablelistview 子项上有一个可点击的 ImageButton?如果是,如何对其事件监听器进行编程?
最佳答案
在您的适配器中,覆盖 getChildView 方法。为包含按钮的 subview 膨胀自定义布局。找到按钮 View 并设置监听器。您可能还想/需要覆盖一些其他 Adapter 方法。
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
View convertView, ViewGroup parent) {
View v = mInflater.inflate(R.layout.expander_child, null);
Button button = (Button)v.findViewById(R.id.expand_child_button);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(ExpandableList1.this, "button pushed", Toast.LENGTH_SHORT).show();
}
});
return v;
}
关于android - Expandablelistview 子项上的 ImageButton,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3081927/