How to implement a large load on Android in the phone?

I have an application in which I show items coming from a service. Here I have about 200 items to display, which is some that are hard to see.

Here I want to display the loading of more functionality, showing the first 20, and when loading more, it will display the next 20 and so on. I can not find a way to implement this, if anyone has an idea, please help me.

+4
source share
2 answers

Loading 200 items and storing them is not a good phone / corridor approach. We are talking about the already slow HTML5 + JS shell, this will make it even slower.

A better approach would be to use ajax to load more data, the ajax call will fire when you reach the end of the list or when the "load new content" button is clicked.

Here you will find the “upload new content” button approach:

http://jsfiddle.net/knuTW/2/

Here you will find an approach with an automatic download list when you reach the end of the list:

http://jsfiddle.net/dhavaln/nVLZA/

This example requires this jQuery plugin: http://imakewebthings.com/jquery-waypoints/

And here is my example with listview and $ .ajax startup in combination:

http://jsfiddle.net/Gajotres/v4NxB/

Sample code, and I repeat that this is just a dummy example (a dummy example still working):

// load test data initially for (i=0; i < 10; i++) { $("#list").append($("<li><a href=\"index.html\"><h3>" + i + "</h3><p>z</p></a></li>")); } $("#list").listview('refresh'); // load new data when reached at bottom $('#footer').waypoint(function(a, b) { // Load some dynamic data with $.ajax $.ajax({url: "http://api.themoviedb.org/2.1/Movie.search/en/json/23afca60ebf72f8d88cdcae2c4f31866/The Goonies", dataType: "jsonp", jsonpCallback: 'successCallback', async: true, beforeSend: function() { $.mobile.showPageLoadingMsg(true); }, complete: function() { $.mobile.hidePageLoadingMsg(); }, success: function (result) { ajax.parseJSONP(result); }, error: function (request,error) { //alert('Network error has occurred please try again!'); } }); $('#footer').waypoint({ offset: '100%' }); }, { offset: '100%' }); var ajax = { parseJSONP:function(result){ //var jsonObj = jQuery.parseJSON(parameters); $("#list").append('<li>Movie name:<span> ' + result[0].original_name+ '</span></li>'); $("#list").append('<li>Popularity:<span> ' + result[0].popularity + '</span></li>'); $("#list").append('<li>Rating:<span> ' + result[0].rating+ '</span></li>'); $("#list").append('<li>Overview:<span> ' + result[0].overview+ '</span></li>'); $("#list").append('<li>Released:<span> ' + result[0].released+ '</span></li>'); $("#list").listview('refresh'); } } 

You also need to prevent another call to $ .ajax to the last.

+1
source

Although I am not very familiar with Phonegap along with Shared Preferences, but a little research, I know that there is no direct way to use the general settings in a telephone bundle (as far as I could look).

  • If you still want to use the general settings in Phonegap, you need to add a plugin for it.
  • Another way I could find is to use Local Storage using HTML5 and JSON .
  • Another way is to implement a database using Lawnchair. Here you will find a good solution and here
  • and one of the most efficient ways I've found so far is Webkit Client side Databse Storage . This is somehow a good coincidence with your problem.
0
source

All Articles