Advertisement
Guest User

Untitled

a guest
Apr 6th, 2011
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.17 KB | None | 0 0
  1. public class DealsView extends BaseListView {
  2.    
  3.     /** Called when the activity is first created. */
  4.     @Override
  5.     public void onCreate(Bundle savedInstanceState) {
  6.         Log.d(TAG, "onCreate()");
  7.         super.onCreate(savedInstanceState);
  8.        
  9.         setActionBarContentView(R.layout.deals_view);
  10.        
  11.     mAdapter = new DealAdapter(this);
  12.        
  13.         downloadDealsFeed();
  14.     }
  15.    
  16.     private void downloadDealsFeed() {
  17.     ...
  18.     }
  19.  
  20.     @Override
  21.     public void handleXmlParsed() {
  22.     Log.d(TAG, "handleXMLParsed()");
  23.  
  24.         runOnUiThread(new Runnable() {
  25.             @Override
  26.             public void run() {
  27.                 setListAdapter(mAdapter);
  28.             }
  29.         });
  30.        
  31.         updateListView();
  32.     }
  33.    
  34.     private void updateListView() {
  35.         runOnUiThread(new Runnable() {         
  36.             @Override
  37.             public void run() {
  38.                 Log.d(TAG, "updateListView()");
  39.                 mDealsModel = ModelManager.getInstance().getDealsModel();
  40.                 mDeals = mDealsModel.getDeals();
  41.                
  42.                 try{
  43.                     mAdapter.notifyDataSetChanged();
  44.                 }
  45.                 catch(IllegalStateException e) {
  46.                     Log.e(TAG, "Error Updating Adapter/ListView", e);
  47.                 }
  48.             }
  49.         });
  50.     }
  51.    
  52.     private class DealAdapter extends ArrayAdapter<DealModel> {
  53.         ...
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement