Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8360859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:33:52+00:00 2026-06-09T11:33:52+00:00

i’m really stuck with this and not able to move forward i’m trying to

  • 0

i’m really stuck with this and not able to move forward i’m trying to populate google calendar events into a listview and am not seeing any results. i’m sorry for posting such lengthy code but i’m really stuck!!
My activity

public class EventListActivity extends Activity {

 private List<Events> events = new ArrayList<Events>();
 private Handler handler = new Handler();
  private ProgressDialog progressBar;
  private SelectableEventsAdapter eventsAdapter;

@Override
public void onCreate(Bundle savedInstance) {
     super.onCreate(savedInstance);
     getAccount();
    setContentView(R.layout.layout_main);
    setEventsListView();
}

private void setEventsListView() {
    Log.i("ReachedsetEvents", "Reached set Events view 1");
     final ListView eventsListView = (ListView) findViewById(R.id.list_main);
     eventsAdapter = new SelectableEventsAdapter(this, events);
     //eventsAdapter.getView(0, eventsListView, eventsListView);
    eventsAdapter.setAdapter(eventsAdapter);
    Log.i("ReachedsetEvents", "Reached set Events view 2");
    eventsAdapter.sort();

     private void retrieveEvents() {
    // Retrieves the attendees on a separate thread.
    new Thread(new Runnable() {

      public void run() {

        EventsRetriever eventsRetriever =
            new EventsRetriever(EventListActivity.this, OAuthManager.getInstance()
                .getAccount());
        final List<Events> newevents = eventsRetriever.getEvents();
        Log.i("reachedRetrieve", "reached retrieve");
        // Update the progress bar
        handler.post(new Runnable() {

          public void run() {
            if (newevents != null) {
              events.clear();
              events.addAll(newevents);

             eventsAdapter.sort();
             eventsAdapter.notifyDataSetChanged();
            }

            Log.d(Constants.TAG, "Got attendees, dismissing progress bar");
            if (progressBar != null) {
              progressBar.dismiss();
              Log.d(Constants.TAG, "Progress bar should have been dismissed");
            }
          }
        });
      }
    }).start();
    // Show a progress bar while the attendees are retrieved from the phone's
    // database.
    progressBar =
        ProgressDialog.show(this, null, getString(R.string.retrieve_contacts_wait_text), true);
  }
           @Override
  protected void onResume() {
    super.onResume();
   // getAccount();
  }

  /**
   * Prompt user to choose an account and retrieve attendees from phone's
   * database.
   */
  private void getAccount() {
    OAuthManager.getInstance().doLogin(false, this, new OAuthManager.AuthHandler() {
      public void handleAuth(Account account, String authToken) {
        if (account != null) {
          retrieveEvents();
        }
      }
    });
  }}

my custom adapter

public SelectableEventsAdapter(Context context, List<Events> items) {
      super(context, R.layout.layout_main,items);
      inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}

  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
   Events item = getItem(position);
    LinearLayout eventsView = getView(convertView);

    setViews(item, eventsView);
    return eventsView;
  }
  private LinearLayout getView(View convertView) {
      Log.i("Reached", "Reached getView long");
      LinearLayout eventsView;
    if (convertView == null) {
         eventsView = new LinearLayout(getContext());
         inflater.inflate(R.layout.layout_main,eventsView,true);

    } else {
        eventsView = (LinearLayout) convertView;
    }
    return eventsView;
  }
  private void setViews(Events item, LinearLayout eventsView) {
        setTitleView(item, eventsView);

      }
     private void setTitleView(Events item, LinearLayout eventsView) {
   ListView titleView = (ListView) eventsView.findViewById(R.id.list_main);
       titleView.setEnabled(true);
    //titleView.setText(item.title);

}

and the retriever for getting the events:

  public EventsRetriever(Activity activity, Account account) {
    this.activity = activity;
    this.account = account;
  }
  public static final String[] FIELDS = {
      CalendarContract.Events.TITLE,
      CalendarContract.Events.DESCRIPTION,
      CalendarContract.Events.ORGANIZER,
      CalendarContract.Events.STATUS,
      CalendarContract.Events.DTSTART,
      CalendarContract.Events.EVENT_LOCATION,

      };


      public static final Uri CALENDAR_URI = Uri.parse("content://com.android.calendar/calendars");

      String[] selectionArgs = new String[] {CalendarServiceBuilder.ACCOUNT_NAME, Constants.ACCOUNT_TYPE,
                CalendarServiceBuilder.ACCOUNT_NAME};


  /**
   * Get the list of user's contacts.
   * 
   * @return The list of contacts.
   */
  public List<Events> getEvents() {
    List<Events> result = new ArrayList<Events>();
    ContentResolver cr = activity.getContentResolver();
    Cursor cursor =
        cr.query(CalendarContract.Events.CONTENT_URI, FIELDS,null,null, null);

    try {
          if(cursor.getCount() > 0) {
            while (cursor.moveToNext()) {
              String title =cursor.getString(cursor.getColumnIndex(
                      CalendarContract.Events.TITLE));
              String description = cursor.getString(cursor.getColumnIndex(
                      CalendarContract.Events.DESCRIPTION));
              String organizer = cursor.getString(cursor.getColumnIndex(
                      CalendarContract.Events.ORGANIZER));
              String status = cursor.getString(cursor.getColumnIndex(
                      CalendarContract.Events.STATUS));
              String location = cursor.getString(cursor.getColumnIndex(
                      CalendarContract.Events.EVENT_LOCATION));
              result.add(new Events(title,description,organizer,status,location));
              Log.i("Reachedretriever", "Reached retriever");
             }

          }}
            finally {
                  cursor.close();
                }
        return result;

        }}

I am not able to see anything getting populated on the screen! Also just so that you know i’m using unauthorised Oauth for the api access.
The layout_main.xml contains just a ListView inside a linearlayout.
Please let me know if you need anything more.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T11:33:53+00:00Added an answer on June 9, 2026 at 11:33 am

    I think the list of events in your adapter is not the same as the list in your activity.

    So either call setAdapter() at last when the list of events is already populated, or create a setter in your adapter

    setItems(List<Events> events){
         this.events = events
     } 
    

    and call it before calling notifyDataSetChanged()

    You might also want to replace your threads/handler implementation with an AsyncTask which is much easier to read and faster to use (IMHO).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.