List menu that open hidden views in it - android

I need to create a list menu where each item, when selected, will open a sub area with others controls (see the example image):
I have two possible solutions in my mind:
Have all the item's controls in RelativeLayout with "gone" visibility, and list them in a LinearLayout.
Use the ExpandableListView, but I have no experience with that and I don't know if this might be a proper solution in my case.
What do you think would be more elegant? Do you have other/better solutions?

You can use ListView as well as ExpandableListView to achive your requirent.
I have done some thing by using ListView and slide animation that suits your requirement.
For Complete reference go through my Android blog
http://amitandroid.blogspot.in/2013/03/android-listview-with-animation.html
Thanks,

Both approach would work but ExpandableListView should be better performance-wise.
You must provide a ExpandableListAdpater, with a layout for your group item and another for the subitems.

Related

What's the best combination of layouts to use to create this effect?

I am trying to create a program with some kind of list which is dropped down when you are clicking in the desired category and reveal some items in there.
I am new to layouts and XML editing, so I would love to have a tip where to start with.
I tried RelativeLayout but then I am stacked.
I don't want you to write the code for me, just some suggestions for what Layout is better to use and I will do my research for that. Thanks.
Use ExpandableListView class, with a custom view for the children :-)

Android: Layout used by wechat

In WeChat, it uses white sections for different things as you can see in below image there are three white sections in it and each item is separated by a black line:
I can suspect this is not a ListView as one might think in first glance.
Question: Does anyone know is this some built-in component that can be used or how to go about creating similar sections ?
I would say a linearlayout inside a scrollview with your custom listview and custom adapter is the most straightforward solution.
Each time the view is inflated you check the shared preference and fill in the info accordingly in your adapter. And on item click you open corresponding fragment/activity that do something. Then you issue a callback to refresh this settings view.
Might not be the most elegant way to do it. But I think this one is easy and clear.
I guess its a preferences activity/fragment but you can create it with a listview, linearlayouts or a combination of a scrollview and a linearlayout.
You have too many solutions ;)

Swipe and change layout of an element of a listview

I am trying to achieve the following effect on my custom list-view: When the user swipes the list element to right the layout of the swiped list item would change its layout. I have tried the SwipeListView approach from GitHub but i didn't manage to implement that through.
Can you give me any ideas on how to achieve the desired effect?
Also please note that i used a merge adapter for a list-view with multiple headers and sections.
Thanks!
Maybe take a look at this question and the links that it provides to give you some ideas.

expandable listview or clickable linear layout

I am trying to create something like (very poorly created in paint) in the image below:
I have only 4 items, and it won't be more. the items contains two textviews. But when you click on an item, i want it to expand, (like item 2) to the bottom with three extra buttons. It would be really nice if there would be some nice expand animation. I don't want this list to be scrollabe, it just need to fits in my screen. And only one can be expanded.
I think there are two options, but maybe i am missing something.
1) Create an itemlayout.xml, containing an linearlayout or something containing the extra buttons, set to linearlayoutbuttoncontainer.setvisibility(View.GONE). And then build a switch, which closes the others than the clicked one, and set the visibility of the clicked item to visible. This would be fairly easy to build i guess, i don't foresee a lot of problems. But is it possible creating an animation or is there only a sudden screen change?
2) expandable listview, with the buttons in the expandable item. I know its possible to make only one item expanded, by rembering the expanded one and closing it again. But is it possible to make it like this, with the buttons in the expandable part? Actually i've never used an expandable view.
Anyone know what the best solution should be?
Thanks
I would recommend using an expandable list view for this, as your second option described. For this type of list you can use a expandable listview adapter, describded here:
http://developer.android.com/reference/android/widget/ExpandableListAdapter.html
This adapter has both a getGroupView(open/close items) and a getChildView method in which you can inflate your layouts, or manually set them up. If you have used ordinary listviews I'm sure this wont be a problem for you, since it's basically the same operations.
This means you should probably inflate your childViews with a LinearLayout containing three buttons. Then you have to implement functionality for your collapse/expand logics by keeping track of which item index is opened.
I did this tutorial when I first started out with exp.list views, I found it helpful:
http://android-adda.blogspot.se/2011/06/custom-expandable-listview.html
Good luck!
You gotta check this http://udinic.wordpress.com/2011/09/03/expanding-listview-items/ it works neat. If you got any more problems, do ask...

SimpleCursorAdapter within a ScrollView

I'm having abit of an issue and i'm not too sure how to go about solving it.
Essentially i have an activity which has a base xml layout of ScrollView and i want this activity to list some results from a Cursor. So i thought i'd use SimpleCursorAdapter... however when i got it all set up it appears that the ListView that the SimpleCursorAdapter goes into doesn't play nice being within another scrollable layout element.
I've sorta got it working programmically but i'd much rather use a ListAdapter as it will make each list entry look like a button and keep it inline with the design of the rest of the application and can handle the ids of each item and where to send the user upon clicking.
So my question is this: is there anyway to either make ListView show all the items such that it never needs to scroll, or can i change the ListView to something like a LinearLayout?
I hope that makes sense!
Any help / insight / ideas are welcome!
Cheers!
You can NEVER use a scroll view and a ListView together. Its a mess! and illogical as well.
Here are some of the approaches you can use:
Theres no screen big enough to show all the content of you listView you can try wrapping up your content but as I said it won't help as scroll view and list view don't work together. So you can either remove your or
If your list items are simple you can dynamically add your views to LinearLayout with specified location
Another tip I can give you is you can always use an relative layout and place your listView alignParentBottom="true" and emit the scrollView approach this will make you listview alwyas scrollable.
It doesn't really make sense to have a ListView inside a ScrollView at all. The ListView implements it's own scroll function so it should not be used in conjunction with a ScrollView anyway.
You should rethink your UI design.
I agree with Shardul; trying to put a listview with a scrollview will make it impossible to scroll. Have a look at the links below to see what you can accomplish with just a ListView -
a.
custom backgrounds info.
custom adapters

Categories

Resources