STITCH: Hiding SECTION when source array is empty?

43 views
Skip to first unread message

niklas8...@gmail.com

unread,
Jan 30, 2014, 4:58:26 AM1/30/14
to android...@googlegroups.com
Hi,

Not sure if this is going to become a double since I just posted about this, but it never showed up...

Anyways, I have a ListView and in itemSource am using STITCH together with a number of SECTION and ADAPTER to display data from several source arrays. However, sometimes the arrays are empty, in which case only the SECTION is displayed. Is there any way to hide the SECTION when the array is empty? Similar to how the contact list in the phone hides the headers A, B and C if the first person has a name starting with D.

I notice this question has been asked before, but I never saw any definite reply indicating that someone managed to get it working and if so: how? 

After reading the discussion about STITCH in this google group, I tried using binding:visibility inside the layout xml for the section but was unable to get it to work (Error when resolving statement 'ShowSection'). I never found any way for the binding inside the section layout xml to find the BooleanObservable I created.

Hope it gets posted properly this time...

Andy Tsui

unread,
Jan 30, 2014, 8:58:11 PM1/30/14
to AndroidBinding
After reading the discussion about STITCH in this google group, I tried using binding:visibility inside the layout xml for the section but was unable to get it to work (Error when resolving statement 'ShowSection'). I never found any way for the binding inside the section layout xml to find the BooleanObservable I created.

Sounds a possible approach, can you post your XML (for both STITCH and the children) and the VM of that section here?


--
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.

niklas8...@gmail.com

unread,
Feb 7, 2014, 5:54:41 AM2/7/14
to android...@googlegroups.com
This is the test code I was creating to see if I could get it working...

in the layout xml for my activity:

...
<ListView 
   style="?android:attr/textAppearanceLarge"
   android:id="@+id/user_details_list"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:padding="16dp"
            binding:onItemClicked="ARG(ListItemClicked, =id/user_details_list.clickedItem)"
   binding:itemSource="STITCH(
   SECTION(@string/user_details_section_details, @layout/user_details_list_section),
   ADAPTER({source=GeneralInfoDetails, template=@layout/user_details_information_item})
    )" />

GeneralInfoDetails is an ArrayListObservable which might contain data about the user, or it might be empty. It is defined in the activity which inflates the xml and this binding is working fine.

In the xml user_details_list_section:

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    binding:visibility="ShowSection"
    >
 
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:textSize="18dip"
   android:gravity="bottom"
   binding:text="."
/>  
<View style="@style/HorizontalDividerView"/>
</LinearLayout>

ShowSection is a BooleanObservable inside the activity inflating the layout.

I was trying a number of combinations, but was unable to get it working... And since I never read any update here or on the blog comments that it was in fact working I decided to post and move on for now :)

Any ideas what might be wrong? Perhaps I am missing something obvious, would be grateful for help.

niklas8...@gmail.com

unread,
Feb 7, 2014, 8:53:14 AM2/7/14
to android...@googlegroups.com
Did I miss or write something inappropriate in my reply today? It's deleted? If I am all wrong in my approach please let me know how I should have been doing it instead :) 

I was searching the demo on Android market for anything related to hiding sections but I couldnt find anything there or on the blog/documentation either, or I wouldnt be asking here...

On Friday, January 31, 2014 2:58:11 AM UTC+1, Andy Tsui wrote:

Andy Tsui

unread,
Feb 7, 2014, 11:10:12 AM2/7/14
to android...@googlegroups.com, niklas8...@gmail.com
I'll answer this short question before reading your code :P

You need to "join" the group to post otherwise the message needs moderate before appearing in the group. 

Niklas Linden

unread,
Feb 7, 2014, 11:28:53 AM2/7/14
to android...@googlegroups.com, niklas8...@gmail.com
Thanks, I have joined now :) 

Niklas Linden

unread,
Feb 12, 2014, 8:13:04 AM2/12/14
to android...@googlegroups.com, niklas8...@gmail.com
So... Any suggestions about how I might get this working? :) If this is something that works for others, I am obviously doing something wrong, so I am grateful for any help.
Reply all
Reply to author
Forward
0 new messages