我有一个带有自定义适配器的可扩展列表活动(ExpandableListActivity)。
如果适配器的自定义行包含imageView,则一切正常,但如果我将此视图从imageView更改为imageButton,则可扩展列表视图不会展开。
有没有什么方法可以放置一个按钮,可以单击该按钮而可扩展列表不失去展开功能?
我有一个带有自定义适配器的可扩展列表活动(ExpandableListActivity)。
如果适配器的自定义行包含imageView,则一切正常,但如果我将此视图从imageView更改为imageButton,则可扩展列表视图不会展开。
有没有什么方法可以放置一个按钮,可以单击该按钮而可扩展列表不失去展开功能?
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 ...
}
});
您不仅可以在类中设置“focusable”属性,还可以在xml中设置,至少对我而言是有效的。
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"/>