is it possible to make an expandable list within an expandable list
i am making a recipe application and i've three expandable lists of the same type - vitamins, minerals and macro-nutrients created with expandablelistview with android studio
is it possible to put these three expandable lists under an expandable list called nutrition and if so could you briefly outline how please. thanks in advance
Short answer, yeah you can but you really really shouldn't.
I've tried this before and it didn't end well, I can't remember the exact reasons but conflicts arise between touch listeners and the measure passes when trying to layout the views inside the different adapters don't calculate correctly.
You can find a number of custom ExpandableLists trying to do what you want around the web but I found they also had similar issues.
What I ended up doing was building my own expandable listview. If you check the source code for Android's ExpandableListView and ExpandableListAdapter you'll find that it's basically
just a regular listview
a list of items that are visible
an Async filter for the data source
some meta data to tell if its a child or group, expanded or collapsed, etc
So if all your item are collapsed the visible list only contains the Group Items.
Expand a Group Item and the async filter gets triggered and populates the visible list with the Group Items and the Children of the expanded Group Item.
Depending on the meta data it will call either getGroupView or getChildView.
So if you want you can take a shot at writing your own.
I wrote a blog post for an ExpandableList that I wrote that does, in theory, infinite levels of expansion. NLevelExpandableListView
Related
I have a simple recyclerView. When scrolling, items are getting fetched from a Room Database and being added to the recycler's list.
I wondering how many items can be added before throws OOM?
Is there any way to control this?
Example: In instagram's search section you cant scroll down forever right?
RecyclerView creates limited number of views, then populate them by your data. So, there is no limits to show the items until some problems happened like reaching the Integer MAX_VALUE (because of containing list position), etc...
Im developing an Android app in Java using Android Studio. I have a layout called activity_way_bill, where it must show a list of trips. Also, I have a layout called item_waybill_trip, where I have labels for displaying the trips details.
I need to insert X item_waybill_trip layouts into the activity_way_bill layout (the X number I will know at runtime). Right now, I just have it included like this, in the XML file:
<include android:id="#+id/trip" layout="#layout/item_waybill_trip" />
But this is a static solution and only allows me to include 1 (or a predefined number) of layouts. I need to include X, and set different texts for each one. How can I do this?
If you want to display the list of element with the same layout but different data than you have to use recycle view.
You can also define the count at runtime and change the count if you needed.
You can visit the site below and check how to use recycle view. :-
https://developer.android.com/guide/topics/ui/layout/recyclerview
As mentioned in the answer by #Mahavir Jain you could use a recyclerview for that but if you want to go the other way, you will have to create the dynamic layouts at runtime and add them to the parent layout using the .addView() method of the parent layout
If your app needs to display a scrolling list of elements based on large data sets (or data that frequently changes), you should use RecyclerView as described on this page.
What I want to create
I want to create a list where each item in that list is an data table like below: The user needs te be able to sort items in the data table and needs to be able to sort the data tables itself.
Each table is going to represent a client and each item in that table is an order. The user will then collect the orders, if he collected an order the order wil dissapear but the user is also able to bring them back.
What I tried
I tried to put a Recyclerview inside a Recyclerview but this caused unitended side effects and bugs, also I read online that it is basically a bad practice. My initial intention was to use a recylcerview with a sortedlist.
I did some searching online and a lot of people recommended using categories between items so that you only need one list. But because I have data tables (CardViews) that can be independent sorted this isn't an option.
If anyone want to give me a nudge in the right direction, I would be really thankful.
What you can do you can use recycler view and in custom row check box with 8 text views and when position is 0 inflate categories like fat, calcium etc and after that position populate data and if you want next button which shows next items in list use fragments or pagination that should do the trick and you can achieve this using single recycler view. You can also use header to show categories.
I have say 3 images in a view and want to display a list upon selecting any of the images. Upon selecting an image a list shows up adjacent to the image that was selected. Only one list can show at a time, so if a list is visible next to one image and another image is selected a new list is built next to the selected image and the existing list disappears.
The lists are built using arrays.
Should I use listview or listactivity. Or might there be a better approach to doing this.
Thanks,
you can use Recyclerview List for your mentioned problem
The easiest way, according to me, is to make the layout as you want with the images and with listviews and put initially visibility gone on the lists. When a image is clicked make that list visible (setVisibility(View.VISIBLE)) and the other ones gone (setVisibility(View.GONE)).
This is the most straightforward solution.
I want to create some kind of ListView which will be expanding and collapsing after click on one of its item. When item of ListView is expanded show additional data. After I click another one first data collapsing and show actual one. I found one solution (https://github.com/SilenceDut/ExpandableLayout) but I'm thinking that should be other ways to do that without using external library. Am I right ?
P.S sorry for weak english
You can do it using Expandable List View:
Tutorial Link :-http://www.androidhive.info/2013/07/android-expandable-list-view-tutorial/