Saturday, 15 September 2012

Custom expandable list in android -


I need to design a page like the picture below. I need to expand two ideas like the Ardi I did the goggle but I was able to see only expandable list view. Can someone advise me about custom two views in a wide window?

If you only have to expand 2 views, then you might see the ExpandableListView Using a simple trick to get it without having to be gone due to sub-categories visibility, linerlightout oriented vertical Define the layout of each category and subcategory. & lt; LinearLayout Android: id = "@ + id / category1" //....> & Lt; / LinearLayout & gt; & Lt; LinearLayout Android: id = "@ + id / subcategory1" Android: Visibility = "gone" //....> & Lt; / LinearLayout & gt; & Lt; LinearLayout Android: id = "@ + id / category2" //....> & Lt; / LinearLayout & gt; & Lt; LinearLayout Android: id = "@ + id / subcategory2" Android: Visibility = "gone" //....> & Lt; / LinearLayout & gt;

Set up a click listener for each category, and when a category is clicked, its visibility changes: visible if it went to Is , and went if it is visible .

A pseudo-cod will look like this:

  ViewGroup category1 = findViewById (CATEGORY1); ViewGroup Subcategory 1 = SearchWebID (Subcategory 1); Category1.setOnClickListener (New OnClickListener) {public void onClick () {toogle ();}}); // void toogle () {if (Subcategory 1 is visible) {Subcategory 1 The requirements will be changed in the future and you need to add more categories, then perhaps  ExpandableListView    / Code> will make more sense, but for now you can get the desired effect from this simple move. / P>  

No comments:

Post a Comment