button in expandable listview android
Asked Answered
D

2

13

i have a ExpandableListActivity with an custom Adapter.

if the custom row of the adapter contains a imageViewall is done, but if i change this view from imageView to imageButton, the expandable listview don't expand.

Is there any method to put a button that can be clicked and the expandablelist does not lose the functionality to expand?

Demitria answered 26/3, 2012 at 22:41 Comment(0)
L
19

The button should be no-focuseable. In your listView.setOnItemClickListener (not in xml layout!!) :

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   ...
    }
});
Lietuva answered 27/3, 2012 at 15:14 Comment(4)
(Buttom) should be (Button)Spense
yet another wtf moment for androidSeeing
Thanks a lot. Have you any explanation about this behaviour? It looks unrelated with the expand functionality from my point of view...Bakst
in my case I have a ScrollView and has the same behaviour in a ListView .. when visible the OnItemClickListener of the list don't work anymore (maybe focus problem, or double scroll problem ... not clear)Kirkuk
H
1

You can set the 'focusable' attribute not just in the class, but in the xml as well, at least it's working for me.

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:focusable="false"/>
Handy answered 25/12, 2015 at 13:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.