Java Code Examples for android.app.ListActivity

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project gmarks-android, under directory /src/main/java/org/thomnichols/android/gmarks/.

Source file: ListsListActivity.java

  17 
vote

protected void doListSync(){
  Toast.makeText(this,R.string.sync_begin_msg,Toast.LENGTH_SHORT).show();
  final ListActivity ctx=this;
  new AsyncTask<Void,Integer,Integer>(){
    @Override protected Integer doInBackground(    Void... params){
      Log.d(TAG,"Starting list sync...");
      ListsSync sync=new ListsSync(ctx);
      DatabaseHelper db=new DatabaseHelper(ctx);
      try {
        sync.synchronizeMyLists(db);
        ((CursorAdapter)ctx.getListAdapter()).getCursor().requery();
      }
 catch (      AuthException ex) {
        Log.w(TAG,"Auth failure",ex);
        return SYNC_RESULT_AUTH_ERR;
      }
catch (      Exception ex) {
        Log.w(TAG,"Lists sync error",ex);
        return SYNC_RESULT_ERROR;
      }
      return SYNC_RESULT_OK;
    }
    protected void onPostExecute(    Integer result){
      int msgID=R.string.sync_done_msg;
      if (result == SYNC_RESULT_AUTH_ERR) {
        msgID=R.string.sync_notify_auth_error;
        startActivity(new Intent(ctx,WebViewLoginActivity.class));
      }
 else       if (result == SYNC_RESULT_ERROR)       msgID=R.string.sync_notify_error;
      Toast.makeText(ctx,msgID,Toast.LENGTH_LONG);
    }
  }
.execute();
}
 

Example 2

From project reddit-is-fun, under directory /src/com/andrewshu/android/reddit/common/.

Source file: Common.java

  15 
vote

/** 
 * Set the Drawable for the list selector etc. based on the current theme.
 */
public static void updateListDrawables(ListActivity la,int theme){
  ListView lv=la.getListView();
  if (Util.isLightTheme(theme)) {
    lv.setBackgroundResource(android.R.color.background_light);
    lv.setSelector(R.drawable.list_selector_blue);
  }
 else {
    lv.setSelector(android.R.drawable.list_selector_background);
  }
}