ListView inside ListView item - java

I want to ask one question, should I use ListView inside ListView item? Or I should redesign and remake my idea?
Example of ListView, but should be with couple sub items:

A ListView inside a ListView item is never a good idea. If you want sublists inside your list you can, for example, use a ExpandableListView. However, with the migration from ListViews to RecyclerViews I would recommend you go and implement this instead.

A ListView will never work correctly embedded as an item in another ListView. In fact, scrolling things inside other scrolling things is almost never what you really want to do, as it would be confusing to the user how to actually navigate your screen.

Related

Listview filter through same names Android

So I have a custom spinner header, where the user can change the title of names based on selection. What I want to do is if they click on the spinner and change the default, then it only shows the names in the listview from the title of names. Currently I have tried this by reinstantiating my fragment from my tabhost, and if conditions are met it would just remove from list everything that doesnt have what user selected. But this is inefficient and it didn't work as the listview wasn't updated and the condition wasn't even getting called on the new instantiation... Is there any filter way I can do for this? Any ideas or help would be great!
You only need to refresh the ListView not the entire fragment. There are several ways to do this, including providing a different data source to the ListView's adapter. The exact details for how to do this depend on whether you are using an ArrayAdapter or a CursorAdapter.

How create Activity with a few ListView?

I have to create Activity with ListView, when I click on item on ListView item and if this item has more items, new List sliding from left side to half of screen and so on...
It should be kind of this
http://a1.mzstatic.com/us/r30/Purple6/v4/d5/92/2a/d5922a96-fccf-508a-52fb-c3a21a8d8d4c/screen480x480.jpeg
Does somebody have some idea?
I don't need code just show me direction, but if you provide some simple example I will be glad to see it:)
Thank you
http://www.vogella.com/tutorials/AndroidListView/article.html
This link has an implementation of how to make a listView. You would have 2 different activites with two listViews. And while implementing the onitemclick method of one listView you will have to set up an intent which will open the second listView activity. Did that gelp?
Even I am new to android so I hope that logic helped. I cannot explain without a code.

Adding Heavy UI in in each ListView Item

I am bit more concern of OOM on having a heavy UI on each item of a listview, example I have 100 items.
Below is the image that I wanted to practice and copy the UI layout. What would be the possible layout or how can I implement this type of UI. Each items are scrollable until the bottom, with separate contents but same layout. Please see my update below.
Update: I am planning to use card ListVIew, please guide me.
You can use simple listView or card ListView but make sure listView raw does not have many nested layout for avoiding nested hierarchy you should use Relative Layout in list raw
I think using a listview with custom row layout will be better for your app.This will help you to reuse the same layouts which are inflated when loading listview.Also please check the size of images you used in the rows.

Tablelayout or custum listView layout

Can anyone tell me on what layout i need to use to create this type of view in android. I thought of going with TableLayout, but i am not sure on this.
Can anyone help me on this.
If the content of the sheet is dynamic, then perhaps a ListView would be more apropriate, as the only thing you'll have to do in order to update the list, will be to notify the adapter that the dataset has been changed.
Another option to consider would be an ExpandableListView. This differs from the ListView by allowing two levels: groups which can individually be expanded to show its children.
(The ExpandableListView can be set to be expanded by default, if you don't want to have it expandable.)

Checkbox in ListView with odd checking behaviour

I am new to Java and Andriod development.
I have a view within my app which contains a ListView
I then have a custom Adapter which inherits from an ArrayAdapter
within the view in the getView method I return a row which contains some text and a checkbox
now so far this all works great my list is populated and I can check my items, and all the events seem to fire as expected.
My problem that I am having is that I check the first 3 items and then I notice that the 11th, 12th and 13th items are checked and as I scroll I see that at regular intervals other checkboxes also seem to be checked in the same pattern.
If I check about 10 checkboxes then it will end up checking all the items in the list of about 80...
can anyone explain what I have done wrong?
I dont think any code will help explain this as I do not set the checkstate of the checkbox anywhere, this is all handled itself, so the fact items are being checked is puzzling me.
Thanks in advance
This is happening because Android recycles list items for performance purposes, here you have the solution of this problem:
ListView reusing views when ... I don't want it to
Hope to help :)
This is expected behavior. ListView reuses views in the adapter.
So what you want is to keep a Set of "selected items" and add an item or remove it when the CheckBox is clicked and then in your getView add the following code:
if(mSelected.contains(getItem(position)) {
checkBox.setChecked(true);
} else {
checkBox.setChecked(false);
}
This way when the row is reused the CheckBox will be the proper status.

Categories