Correct way to STITCH single item

47 views
Skip to first unread message

progr...@gmail.com

unread,
Jul 18, 2013, 2:31:51 AM7/18/13
to android...@googlegroups.com
I have a ListView whos contents are STITCHed together.
There is a SECTION, an ArrayListObservable with one item, another SECTION, and an ArrayListObservable with many items.

I know that first ArrayListObservable will only ever have 0 or 1 item in it. So I'm not sure I really need a whole ArrayListObservable for it.

Can you STITCH non-collections? Should I have that part be an ObjectObservable or something?
What is the best way to handle this situation?

Thanks!

Andy Tsui

unread,
Jul 18, 2013, 4:54:44 AM7/18/13
to android...@googlegroups.com
You don't need ArrayListObservable for one/zero items.

SECTION can bind to anything, an Observable<Object> to a single
String, although I have no idea what VM you have, but if you need to
handle zero/one items, you may do in this way:

1. the SECTION binds to @layout/zero_one_item
2. in zero_one_item.xml,
<LinearLayout visible="IsNotZero">...
3. in the Vm of that single item, have IsNotZero (booleanObservable)

Andy
> --
> You received this message because you are subscribed to the Google Groups
> "AndroidBinding" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to androidbindin...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Chris Blume

unread,
Jul 19, 2013, 5:46:29 PM7/19/13
to android...@googlegroups.com
Thank you for the reply.

Can SECTION only handle a single String? I need it to be a String and an image.

Andy Tsui

unread,
Jul 19, 2013, 9:14:43 PM7/19/13
to android...@googlegroups.com
No, for SECTION you can put anything there as VM, I'd better call it "Single-Item-ArrayList"

Andy

Chris Blume

unread,
Aug 21, 2013, 4:30:54 PM8/21/13
to android...@googlegroups.com
I have a new question about this.
I used a SECTION for the zero-or-one-item and tried adding the binding to the visibility.
But it seemed to have two problems for me:
1.) It seemed to always be visible. Perhaps I just didn't setup the visibility correctly. And,
2.) I could not press up/down to navigate to it. Nor could I click it. The item seemed to be excluded from navigation and interaction.

Did I perhaps do something wrong?
Thanks!

Andy Tsui

unread,
Aug 21, 2013, 8:23:40 PM8/21/13
to AndroidBinding
and a ZERO_ONE converter

For the singleton adapter, you need to report collection size as zero in case of not visible. ZERO_ONE converter is just a hook to use it. 
Reply all
Reply to author
Forward
0 new messages