I want to scroll two ListView in a layout - android

I have 2 ListView in a layout. I want each ListView show all their items. And scroll the whole layout.

A answer from one of the ListView Developers from the GoogleIO is: Never put a ListView in a ScrollView. This means if you want a ListView that is not scrolling as you are trying to do you maybe don't need a listview at all.
You could create a ListView put a Linearlayout in it and use the Adapters from the two Listviews to manually add the items of the list via linearlayout.addView Now you have one scrollable view that contains all items of the list. Because there is no recycling and only loading of the items in the list this is very inefficient and only usable if you don't have that much items.
The second more complicated way that you can go if you have say 20 items in each list is to use a custom adapter that takes the two listadapters and let you put all the items in one list.

Related

Three level ListView with dynamic data

I’m trying to implement three level list views where only the top level is required to be scrollable. Example of the UI is as below:
List view 1: List of houses : scrollable
List view 2: List of rooms in houses : Not scrollable
List view 3: List of windows in the rooms : Not scrollable
Important thing is that the data I fill up needs to be dynamic. So the number of items in the list view 2 and 3 can be changed.
I don’t want list view 2 and 3 as scrollable as they are not going to have too many items, and I want them to be displayed always. Therefore, only top level list view is required to be scrollable.
I tried with 3 level expandable list views but I really don’t need expandable list views as they increase the number of clicks to view all the information at one time.
I tried is to add ListView within ListView and adding adapter to add items in the low level list views. But its not working. It displays only top level list view but the child list view is not displayed at all.
Is there any way to add ListView within ListView as above?
If there is not much item in listview 2 & 3 then do not use listview for level 2,3.
Use a listview for 1, LinearLayout for 2 & 3 and add textView dynamically to those layouts.
Put 2,3 layout to another linear layout and align it to bottom ... so remaining place above those view will be covered by listview.
Comment if my answer is not clear or you need more explanation.

Inner List in Android

I have a problem with lists.
I want to implement a scrollable big list, each element of which contains a text on the left side and a NON-scrollable inner list on the right side. (for example: the name of the flat and the list of its inhabitants names)
Both lists should be filled from the cursors and contain an informatio about them: I want to have an oppurtunitz to get all cursos fields when I click an element of the inner list.
As far as I understood I's not possible to solve it with two ListViews. ExpandableListView does not pass me because I do not want to expand the first list, I want to have the inner list always visible.
Do you have any ideas how can I realize it?
Try using a ListView for your big list, and an empty LinearLayout in each item. You fill the LinearLayout of each item programmatically in the big list adapters getView(..) method, where int position is the item number.
See also: android nested listview
Edit: Or use an ExpandableListView, which items you expand programmatically without animation with expandGroup(int position, boolean animate). Prevent collapsing by setting an ExpandableListView.OnGroupCollapseListener, in which you expand the group again. (seems a bit hacky)
Dokumentation: https://developer.android.com/reference/android/widget/ExpandableListView.html

Android listview with horizontal lines when empty

I have a Listview in my Android app, and I want there to be some horizontal lines when the list is empty to indicate to the user that this is a List. I know that there is the setEmptyView method on ListView, but I'm not sure what to put in that view if I want there to be list rows with horizontal lines. How would I accomplish this?
Having a bunch of horizontal lines for an empty list is an iOS convention. If you want your app to fit in with Android better you should set something else. Perhaps notify the user there was an error or that there are no items in the list. You can add this right to your layout.xml file if you're using a ListActivity. All you need to do is create a view and give it the id #android:id/empty.
put the listView in a FrameLayout and add another view in that Frame.
if you having any item in the list hide its (visiblity="gone") and show the other view.
OR
change your adapter to return multi ViewType
in your adapter if you have no item return other type of view

ExpandableListView within a ListView

Is it possible to have an ExpandableListView within a ListView in android? I only need one item on the list to expand.
Generally you display one or more items in listview. But there are more items for example 100 items in listview then you can use load more button in listview which display more items when user click on it. I think you refer this.

Can I use a ListView inside another ListView

I want to design my app. with more modularity. In my app most of the screens are ListViews, and with similar list items.
For eg. I have 3 ListViews, each for a different category. (Music list, Audi list, Video list) and 1 Main view, that list latest 2 list items of each category.
My Plan is to reuse the 3 inner ListViews on my Main view as as list items.
If you want to have a multi-list view (each item having or not a subitem), you can use an ExpandableListView.
I am not completely sure if that's possible but the first thing I would try is an ExpandableList.
Check this so question:
How to add image in expandable List in parent in android?

Categories

Resources