I wanted to know that is there any way to have multiple HeaderViews for a ListView or on the other hand i want to implement a ListView with three static rows at top and other rows with an adapter which will loaded from AsyncTask,according to ListView recycling i can't make three first row static by using position in getView() function of my adapter body. is there any suggestion to this issue?
If your data is static and always visible, then just put it outside of your listview, above it. And you should have the effect you need.
I used this Library it was useful for implementing Multiple Header ListView, if the first three rows are static then you can add them statically first above the ListView then set the adapter for the ListView and in this case you don't need to use the library
Wrap three views inside a layout (For example a vertical LinearLayout), and add that layout as the list header.
Related
I have an layout like this:
I have almost 10 category to display, and each category have 10 books to display.
So it seems that I have to use the ListView for category with nested ListView for each book.
But I wonder if this will cause the measure problem? The inner book listivew does not need the scroll feature while the outer listview needs.
I have thought use the LinearLayout instead of ListView at all by adding each book and category dynamically , however I am not sure about the performance since the ListView can reuse some view, while LinearLayout cannot(or hard to).
Any suggestion?
Have you tried using ExpandableListView. Hope this helps..
You should not have problems, your inner ListView will not have limited height.
Consider using a ExpandableListView, the header will be the category and the childs the books. If you use this remember to override the method isChildSelectable to keep all the items expanded and remove the group indicator with setGroupIndicator(null).
I want to show a fairly complex header above an ExpandableListView. The header basically holds some artwork and some text. When I scroll the List I want the header to scroll off the screen.
I can do it by adding a section to the list view with no children but it makes my BaseExpandableListAdapter very clunky. does anyone know of a better way. I've tried adding the header in the xml before the ExpandableListView tags but that makes it static at the top of the page when I scroll the ExpandableListView.
if you do not like native View header http://developer.android.com/reference/android/widget/ListView.html#addHeaderView(android.view.View) you can inflate special view and return it in the first position in your Adapter.
Actually we make adapter to control getting view in our ListView. So you can always return special views in special positions and for me that is ok. Not always view in your ListView must be similar. You just need to implement some populating logic for all this views.
Good luck!
I have the following prototype:
What is the way to list views in a scroll-able way in a screen?
What I have already tried:
I tried to create a class and extends the LinearLayout class and dynamically adds my Views (the compound controls class is my view also extends LinearLayout) to the main LinearLayout. So I got a list of my views which is scroll-able.
I'm not sure what you mean, but looking at what you have tried, what's wrong with using a ListView? As the name implies, it should do exactly what you want:
What is the way to list views in a scroll-able way in a screen?
Here is a quote from the android documentation of a ListView
ListView is a view group that displays a list of scrollable items. The
list items are automatically inserted to the list using an Adapter
that pulls content from a source such as an array or database query
and converts each item result into a view that's placed into the list.
You should be able to add a ListView directly as a sub-view under your LinearLayout.
your questions seems like hard to understand.
did you mean how to set the whole page(activity) into a listview?
listviews are scrollable in default (of course, you can see it if the list is long enough and you can set the whole activity as a list).. you can customize it also by using templates (xml)
and extending ArrayAdapter of your type (let's say ArrayAdapter<UpcomingEvents>) and supply data from db...
is this what you mean?
I already have a ListView where each row contains two TextViews and a ImageView. But what I want to do now is to add number of ImageViews into my row. How can i do it? is it by using Nested listviews how to do it? and can i use the same id android:id="#android:id/list"
You should either go for ExpandableListView, and add the
TextViews to your parentView renderers, or
You can create your
own renderer for the list, where each item is a View containing the
two TextViews and a ListView.
Your inner ListViews can have any id attribute, since it does not need to be unique, and from the Adapter implementation you will always know exactly where you are (in the tree).
A sample implementation of a nested view can be found here.
hi I want to use a listview (probably) is it possible to fill each entry with say two buttons two text areas, and have them laid out with realtive or linear layouts?
I have used a scroll view with layout inflator to achieve this at the moment, but I'm thinking listview would be better maybe?
yes you can. you need to use a custom list view for that. making an activity by adding a listview in it and then referencing another xml to that listview using an AAdapter so that every element of the listview has the layout of the second xml file. this tutorial should help you understand the idea.
Yes you can place any widgets for the particular List Item for your listview.
For defining that kind of ListView, you have to define a custom adapter, follow the below steps:
Define a one row file for the list item, say for example, RelativeLayout with 2-3 TextViews.
Define a class by extending BaseAdapter.
Inflate the XML and do display operations inside the getView() method of this class.
Set this adapter to the ListView.