ExpandableListView with Row Button

2,106 views
Skip to first unread message

mark

unread,
Apr 16, 2012, 10:00:12 PM4/16/12
to AndroidBinding
With android binding is it possible to have a button on an expandable
listview - e.g. on MasterItem in the MarkupDemo - if I add a row
button to the Master_template the expansion stops working - I think
this is because focus moves to the button.

Andy Tsui

unread,
Apr 16, 2012, 10:48:43 PM4/16/12
to android...@googlegroups.com
Not sure what do you mean by row button, do you have some screenshot or example?

mark

unread,
Apr 16, 2012, 11:30:53 PM4/16/12
to AndroidBinding
Andy,
Say in the MarkupDemo I wanted to add two buttons to a MasterItem Row
- I could make the master_template.xml file look like
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/
android"
xmlns:binding="http://www.gueei.com/android-binding/"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >

<TextView
android:id="@android:id/text1"
android:layout_width="wrap_content"
android:layout_height="?android:attr/listPreferredItemHeight"
android:paddingLeft="?android:attr/
expandableListPreferredItemPaddingLeft"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center_vertical"
binding:text="."

/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="boo"
android:state_focused="true"
binding:onClick="OpenCloseCmd"
/>
<</LinearLayout>


This would place a button on each row of a MasterItem - which I would
like to be able to click and activate a command. The trouble is when I
add the button it takes focus and the expander no longer works.

I found a possible solution to this known problem on the web:
http://stackoverflow.com/questions/9880950/button-in-expandable-listview-android

But this solution is without androidbinding:-

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

Button button = (Buttom) 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 ... } });
}

Regds
> > this is because focus moves to the button.- Hide quoted text -
>
> - Show quoted text -

mark

unread,
Apr 16, 2012, 11:32:25 PM4/16/12
to AndroidBinding
Sorry I meant add a button (not two buttons although I might need to
add another at some stage).
> I found a possible solution to this known problem on the web:http://stackoverflow.com/questions/9880950/button-in-expandable-listv...
>
> But this solution is without androidbinding:-
>
> The button should be no-focuseable. In your
> listView.setOnItemClickListener (not in xml layout!!) :
>
> Button button = (Buttom) 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   ...     } });
>
> }
>
> Regds
>
> On Apr 17, 2:48 pm, Andy Tsui <gueei....@gmail.com> wrote:
>
>
>
> > Not sure what do you mean by row button, do you have some screenshot or
> > example?
>
> > On Tue, Apr 17, 2012 at 10:00 AM, mark <pmhmcbr...@gmail.com> wrote:
> > > With android binding is it possible to have a button on an expandable
> > > listview - e.g. on MasterItem in the MarkupDemo - if I add a row
> > > button to the Master_template the expansion stops working - I think
> > > this is because focus moves to the button.- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -

Andy Tsui

unread,
Apr 16, 2012, 11:41:20 PM4/16/12
to android...@googlegroups.com
So, in such a way, could we just make the button android:focusable="false"?

Andy

mark

unread,
Apr 16, 2012, 11:48:17 PM4/16/12
to AndroidBinding

Andy,
Sorry in my example above I meant show as "false"
android:focusable="false"

But anyhow this still stops expander from working - any suggestions?
Regds

mark

unread,
Apr 17, 2012, 12:03:53 AM4/17/12
to AndroidBinding
Andy,
My apologies - that does work - I having a bad day with typos - I now
just need to make sure the button command binding will work.

Thanks for your help.

Regds

mark

unread,
Apr 17, 2012, 12:18:49 AM4/17/12
to AndroidBinding
Andy,
Binding all appears to work fine on the button.
Thanks once again.
Regds

On Apr 17, 4:03 pm, mark <pmhmcbr...@gmail.com> wrote:
> Andy,
> My apologies - that does work - I having a bad day with typos - I now
> just need to make sure the button command binding will work.
>
> Thanks for your help.
>
> Regds
>
> On Apr 17, 3:48 pm, mark <pmhmcbr...@gmail.com> wrote:
>
>
>
> > Andy,
> > Sorry in my example above I meant show as "false"
> > android:focusable="false"
>
> > But anyhow this still stops expander from working - any suggestions?
> > Regds- Hide quoted text -
Reply all
Reply to author
Forward
0 new messages