0

Sorry for my English. Before i load all data if user enter to apps, i use isynk task. But now i need use lazy load(example:instagram), if i have not internet i can see last post(image, text). if i drop down list, load new data. I cant understand how make this. This is my structure project now:

//this i load json
ArrayList<NewsObject> newsList; 
ListView list; 

protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    //code
    list = (ListView) findViewById(R.id.list); 
    newsList = new ArrayList<NewsObject>(); 
    //code  
    //load data(json)
    new NewsAsynkTask().execute(); 
} 

public class NewsAsynkTask extends AsyncTask<String , Void, String> {         
    //code 
    protected String doInBackground(String... params) { 
        //this i add json to object,  
        //then i add in list object 
        newsList.add(newsObject); 
    } 

    protected void onPostExecute(String file_url) { 
        //adapter in game
        NewsAdapter adapter = new NewsAdapter(getApplicationContext(), R.layout.n_news_list_object, newsList); 
        list.setAdapter(adapter); 
    } 
} 

And then adapter display all. I see example, but i cant understand how i get json, and then add in lazy load. Ples give me explain or simple lesson

NoNaMe
  • 6,020
  • 30
  • 82
  • 110

1 Answers1

0

Here you have to cache the previous loaded results (NewsList). On opening of application you will fetch the NewsList from Cache (this will be faster), then you can look for the new updates from the service (instagram).

For update on pull check this tutorial http://www.tutecentral.com/android-pull-to-refresh/

Dilip Kumar
  • 2,504
  • 2
  • 17
  • 33