[英]button in expandable listview android
我有一個自定義適配器的ExpandableListActivity。
如果適配器的自定義行包含imageViewall已完成,但如果我將此視圖從imageView更改為imageButton,則可擴展列表視圖不會展開。
是否有任何方法可以放置一個可以單擊的按鈕,並且expandablelist不會丟失擴展功能?
按鈕應該是不可聚焦的。 在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 ...
}
});
您不僅可以在類中設置'focusable'屬性,還可以在xml中設置,至少它對我有用。
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.