vuonghungvinh / tree-view-list-android

Automatically exported from code.google.com/p/tree-view-list-android
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

Indentating the child nodes expandable icons #8

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I was wondering how can i indent the expandable icons. I want the expandable 
icon to be indented if it also has children.

I tried modifying the populateTreeItem()in abstractreeviewadapter and indent 
the image if its at level >1 and has children..but that didnt work.
Thanks

Original issue reported on code.google.com by jayasund...@gmail.com on 9 Aug 2011 at 5:18

GoogleCodeExporter commented 9 years ago
Hello I have made a small modification to make it possible for you. In abstract 
adapter I added the method:
protected int getTreeListItemWrapperId()

and it returns the id of layout that is used to "wrap" list item - you can copy 
the default one (tree_list_item_wrapper.xml) and make necessary modifications 
there:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
    <LinearLayout android:id="@+id/treeview_list_item_image_layout" android:layout_width="80dip"
        android:layout_height="fill_parent" android:gravity="right|center_vertical">
        <ImageView android:id="@+id/treeview_list_item_image" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:src="@drawable/collapsed" >
        </ImageView>
    </LinearLayout>
    <FrameLayout android:id="@+id/treeview_list_item_frame" android:layout_width="fill_parent"
        android:layout_height="fill_parent" android:layout_weight="1">
    </FrameLayout>
</LinearLayout>

Original comment by jarek.po...@polidea.pl on 9 Aug 2011 at 9:53

GoogleCodeExporter commented 9 years ago
Can you please explain your answer in detail. I 'm not sure how would i use the 
id. The linear layout needs to be shifted right for each child node if it has 
children.
So I have a tree like this

+ROOT
   -CHILD1
   -CHild2
   +CHild 3
           -CHILD4
           -CHILD5
NOw I have to move the + sign to the right for child3 as it has children.
Thanks 

Original comment by jayasund...@gmail.com on 9 Aug 2011 at 4:38

GoogleCodeExporter commented 9 years ago
Are you suggesting that i create a new xml for every subsequent child with 
children should have its own?? So that would mean if i have a 5 level tree i 
will require 5 more xml files??

Original comment by jayasund...@gmail.com on 9 Aug 2011 at 4:41

GoogleCodeExporter commented 9 years ago
Not really. You need to replace the wrapper with your own layout:
My code calculates the width of @+id/treeview_list_item_image_layout based on 
the level. What you could do is to change the wrapper and put the image behind 
the FrameLayout (@+id/treeview_list_item_frame) which is where the main content 
of the list item is placed. Something like (but you have to figure out the 
details like width, gravity and so on....) :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
       <LinearLayout android:id="@+id/treeview_list_item_image_layout" android:layout_width="80dip"
        android:layout_height="fill_parent" android:gravity="right|center_vertical">
    </LinearLayout>
    <FrameLayout android:id="@+id/treeview_list_item_frame" android:layout_width="fill_parent"
        android:layout_height="fill_parent" android:layout_weight="1">
    </FrameLayout>
        <ImageView android:id="@+id/treeview_list_item_image" android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:src="@drawable/collapsed" >
    </ImageView>
</LinearLayout>

Original comment by jarek.po...@polidea.pl on 9 Aug 2011 at 4:53