我有一个带有自定义适配器的ExpandableListActivity。
如果适配器的自定义行包含imageViewall已完成,但如果我将此视图从imageView更改为imageButton,则可扩展列表视图不会展开。
是否有任何方法可以放置一个可以单击的按钮,并且expandablelist不会丢失要扩展的功能?
答案 0 :(得分:19)
按钮应该是不可聚焦的。在listView.setOnItemClickListener中(不在xml布局中!!):
Button button = (Button) view.findViewById(R.id.yourButton);
//where button is the button on listView, and view is the view of your item on list
button.setFocusable(false); /// THIS IS THE SOLUTION
button.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
//button functionalty ...
}
});
答案 1 :(得分:1)
您可以设置“可聚焦”'属性不仅在类中,而且在xml中,至少它为我工作。
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"/>