可扩展listview android中的按钮

the*_*sic 13 android expandablelistview expandablelistadapter

我有一个自定义适配器的ExpandableListActivity.

如果适配器的自定义行包含imageViewall已完成,但如果我将此视图从imageView更改为imageButton,则可扩展列表视图不会展开.

是否有任何方法可以放置一个可以单击的按钮,并且expandablelist不会丢失扩展功能?

Sol*_*ety 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   ...
    }
});
Run Code Online (Sandbox Code Playgroud)