Patriotic
Patriotic

Reputation: 2300

How to increase the performance of a scrollable listview which consists a non-scrollable gridview?

I have a listview where each item is showing a month calendar. In each item I have a gridview to show the date. So, by scrolling the list item I can see the calendar month is changing. But scrolling of listview is not smooth. By searching for the solution I have got so far that there are 5*7 =35 items in gridview rendering which makes the scrolling slow. So, I change the getItem() of Grid Adapter by returning only a text view instead of my layout.

I also used a AsyncTask to load the data which is then fed to the grid adapter. But still the scrolling is slow. If there is any alternating solution instead of creating 35 (each view for single date) views with loop, kindly let me know.

Here is the image for understanding the problem. We can scroll in both side:

enter image description here

There are lots of code regarding this.

Upvotes: 0

Views: 95

Answers (1)

egoldx
egoldx

Reputation: 1520

Use viewTypes (override getItemViewType(int pos) and getViewTypeCount()) in yout adapter. One view type will be title(e.q. textView NOVEMBER 2016), second type will be header (probably LinearLayout with textViews - SUN MON TUE WED THU FRI SAT) and third type will be LinearLayout with TextViews containing days.

Another way could be to recycle views inside of your calendar (the GrideView would keep the views infalted and you would only change its visibility and text)

Upvotes: 0

Related Questions