Android GridView : Adding items to a rendered gridview - android

I have a GridView with multiple rows and each row having 2 columns.
Let's say 10 rows are being displayed and on click of a button I want to make a call to the database fetch some more items and display these items below the previously rendered items in the same GridView.
I am using CursorLoader for my DB calls.
I tried the following approach:
Swapping the grid adapter with the new fetched Cursor.
But this makes the whole GridView redraw itself.
Whereas I want it to just add items below it.
Any suggestions or pointers on this would be really helpful
P.S. Fetching the items in any manner is not a problem.

Related

Android dynamic listView: removing items that are not displayed from ListView adapter

I'm going to implement a dynamic ListView: By spending little time, ListView will populate more items from a local file when you are scrolling downward.I used technique like this to implement such dynamic list:http://mobile.dzone.com/news/android-tutorial-dynamicaly
Problem: Number of Items to be displayed is too large. So if I just keep adding them to data source of ListView Adapter, data source will consume too much memory and finally it will lead to application crash by scrolling more and more.
Question: How can I remove some of items that are not displayed from datasource of ListView such that user do not get noticed? It is not important that user need to wait while scrolling up/down for fetching data.
when you are using listview using base adaptor then adaptor will automatically get called whenever user perform scroll and auto destroy unseen elements.

Irregular Gridview, first row with one colum, rest id the rows with two columns

I'm trying to implement an irregular gridview for my Android app. I've defined the gridview to show 2 columns but I need to show just 1 column at the first row. Is it possible using a DataAdapter?
I don't think you can accomplish this with a gridview. The adapter simple provides the data, but the view decides how to lay it out. If your requirements allow you to make the number of columns constant, then maybe you can use the gridlayout instead. I'm thinking you could try to do you layout like the google currents app.
Gridview and ListView are super useful if you have 1000's of items since it reuses views as it scrolls. If you have lots a items in your grid, then I would probably try to use the GridView or ListView to accomplish your goal. Maybe you have to get your requirement changed. Another option is to use a ListView, but sub-divide each row into 2 columns.

change date difference when application loads

So im using a SimpleCursor Adapter to load up my task list, and in each row there is a text view with the time left in it. What i want to do is update the list rows when the user goes to the listview activity so it will update the time left. the problem im having is simple cursor adapters fill the list with items from the database and i need to change the time left text via android by calculating it on the fly and only accessing the DB for the datedue.
I tried storing the timeleft into the DB then updating it when the list is shown but thats not working and seems pretty messy.
edit: I do know how to calculate the time difference. All i want to know is how can i fill a list with Cursor items and non-cursor items.

Endless Adapter with custom listview adapter in android

I am using this link to create custom listview in my app.
First I want to display listview with 5 items. As I scroll the list it should parse data and load listview for next 5 items.
Listview row contains 5 textviews.
How can I achieve this?
Please help me.
Thanks in advance
I want to display 5 items in single row
That has nothing to do with EndlessAdapter. That has everything to do with the ListAdapter you are putting into the EndlessAdapter. Start by not using EndlessAdapter and getting your list looking the way you want. Then, and only then, add in EndlessAdapter to add more data to the list as the user scrolls.
There are countless examples online of how to create rows in a custom ListAdapter that have more than one thing in them. Here is a free excerpt from my book on how to subclass ArrayAdapter, override getView(), and handle more than one widget in a row. You specifically will want to look at the "Customizing the Adapter" section.

How to implement efficiently a gridview layout

This layout is a shelf with 3 books each row.
I current come up with gridview for displaying the books and manually add up the shelf bar. The problem occurs when there are more than 9 books and the layout is broken when scrolling the grid.
Could anyone suggest me another better way to deal with this layout. Thanks
I think you should set the background in each element (one shelf) instead of the setting the Grid container background (three shelf) ....
it's looking difficult in your case because it would has three images in a row ..So you need to try some this switch(position%3) in getView of adapter to set three different image
or
Use the ListView and Re-set the data in Array List so that each element has three books and you can make all three images clickable of that row and can make list row unclickable and unfocusable

Categories

Resources