Updating ListView peridoically

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Updating ListView peridoically

Postby williamzanelli » Sun May 03, 2009 6:03 pm

Hi guys,

I have a ListView, that needs updating every 10-15 mins.

I'm trying to use this [http://www.anddev.org/the_pizza_timer_-_threading-drawing_on_canvas-t126.html] tutorial to update the ListView, I dont know how to adapt this to update my ListView.

Any ideas/pointers from anyone?

Thanks for your thoughts

Will
Will
williamzanelli
Experienced Developer
Experienced Developer
 
Posts: 63
Joined: Mon Jan 05, 2009 2:37 am
Location: UK

Top

Reply

Postby satishkumar_lskin » Tue May 05, 2009 9:38 am

Hi william ,
Your activity will be extending ListActivity I guess. In that case u would have used
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. setListAdapter(myAdapter) ;
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


In ur myAdapter class , u would have a getView() method. U can set some boolean variable in the Adapter class and invoke the onContentChanged() method in ListActivity.

For example,

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.  class MyAdapter extends BaseAdapter{
  3.  
  4.  
  5.  
  6.                    private boolean loadNewView = false;
  7.  
  8.                    ..............................
  9.  
  10.                    .................................
  11.  
  12.  
  13.  
  14.   public View  getView(int position, View convertView, ViewGroup parent) {
  15.  
  16.                    View view = null;
  17.  
  18.                    if(loadNewView){
  19.  
  20.                                 view = ............... ;
  21.  
  22.                    }
  23.  
  24.                    else{
  25.  
  26.  
  27.  
  28.                                view = ................;
  29.  
  30.                  }
  31.  
  32.         return view;
  33.  
  34.  
  35.  
  36. }
  37.  
  38.  
  39.  
  40. public void setLoadNewView(boolean b){
  41.  
  42.           loadNewView = b;
  43.  
  44. }
  45.  
  46.  
  47.  
  48. }
  49.  
  50.  
  51.  
  52.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


Then, u could use the following to do any update to the ListView :
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. ListActivity app = yourListActivity;
  2.  
  3.  
  4.  
  5. myAdapter.setLoadNewView(true);
  6.  
  7.  
  8.  
  9. app.onContentChanged();
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
satishkumar_lskin
Developer
Developer
 
Posts: 32
Joined: Mon Oct 20, 2008 8:15 am
Location: Coimbatore , TamilNadu, India

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 4 guests