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

  • Home
  • SEARCH
  • 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 7074909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:06:52+00:00 2026-05-28T06:06:52+00:00

I am trying to create a calendar using the Gallery widget. I have a

  • 0

I am trying to create a calendar using the Gallery widget. I have a monthview class that handles creating a view for a specific month. My MonthGallery class uses monthview as its child views while my monthviewadapter creates the monthviews for the monthgallery. The problem I am having is trying to update the adapter with the previous and next month while the user scrolls or flings to the previous or next month. I use the position given in the gallery onItemSelectedListener to add months to the front and back of the adapter depending on this position. For example:

OnItemSelectedListener mGalleryOnItemSelectedListener = new OnItemSelectedListener() {

    @Override
    public void onItemSelected(AdapterView<?> adapterview, View view, int position, long id) {

        MonthView mv = (MonthView) view;
        int month = mv.getMonth();
        int year = mv.getYear();
        updateMonthBar(month, year);


        if ((position + 1) == mMonthViewGallery.getCount()) {
            if (Calendar.DECEMBER == month) {
                mMonthViewAdapter.addView(Calendar.JANUARY, year + 1);
            } else {
                mMonthViewAdapter.addView(month + 1, year);
            }
            mMonthViewGallery.setSelection(position);
        }

        if (0 == position) {

            if (Calendar.JANUARY == month) {
                mMonthViewAdapter.addViewToFront(Calendar.DECEMBER, year - 1);
            } else {
                mMonthViewAdapter.addViewToFront(month - 1, year);
            }
            mMonthViewGallery.setSelection(1);
        }
    }

PROBLEM
Once the user has scrolled to another month and then tries to scroll to the first month the gallery does not automatically snap to the next selection. In the adapter, when addView(int month, int year) is called it will call notifyDataSetChanged() so that it updates the gallery with the previous or next month but this seems to cause the unexpected “snapping” while scrolling slowly. Just not sure how to structure this so that scrolling is smooth.

EDIT
I am now using Gallery.setCallbackDuringFling(false) but is there a way to disable the onitemselected callback while scrolling the gallery and then call onitemselected() when it’s done scrolling?

  • 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-05-28T06:06:52+00:00Added an answer on May 28, 2026 at 6:06 am

    used gallery from Does a replacement for Gallery widget with View recycling exist?

    removed one line from onScroll()

    postDelayed(mDisableSuppressSelectionChangedRunnable, SCROLL_TO_FLING_UNCERTAINTY_TIMEOUT);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create my first AppWidget using the AlarmManager class so that I
we are trying to create a calendar function in python. we have created a
I'm using a calendar table as a join table and trying to create a
I am trying to create a calendar view for events. Before my trials this
I am trying to create a calendar instance. I have imported the java.util.calendar but
I am trying to create a PHP script that will create a calendar event
I'm trying to create a calendar class in php and am having issues returning
I'm trying to create a widget that will create a military time string from
I've been trying to create a simple calendar interface using a table, but I
I'm using Exchange web services, trying to create a calendar entry in another user's

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.