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 9240919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:16:15+00:00 2026-06-18T08:16:15+00:00

I have a ViewPager using the Android support framework, which loads three fragments. The

  • 0

I have a ViewPager using the Android support framework, which loads three fragments. The user can navigate between them by swiping.

The second fragment contains two GridViews, each filled with Buttons, using an Adapter.

The two GridViews are named (in XML) left_buttons and right_buttons. left_buttons is controlled by CategoryAdapter that extends BaseAdapter, and right_buttons is controlled by ItemAdapter that also extends BaseAdapter.

The problem that I’m having is that when a user clicks a button in CategoryAdapter, I would like to call notifyDataSetChanged() on ItemAdapter, followed by invalidateViews() on the associated GridView. Because the two adapters are created within the same fragment MenuFragment, I’m struggling to find the best way to communicate between them.

I’ve seen a lot of answers on communicating between fragments, and between fragments and activities, and so on. I tried getting a reference to R.id.right_buttons from within the CategoryAdapter, but couldn’t find a solution (since no access to findViewById etc).

Then, I read some answers that suggested I need to create a method in the Fragment, so I tried the following in MenuFragment.class:

public void updateRightGrid() {

//grab a reference to the right hand grid right_buttons
GridView rightButtons = (GridView) getView().findViewById(R.id.right_buttons);

    //get the adapter that is controlling right_buttons
ItemAdapter menuItemAdapter = (ItemAdapter) rightButtons.getAdapter();

    //tell this adapter that we have some new data, so please refresh
menuItemAdapter.notifyDataSetChanged();

//force the grid to refresh
rightButtons.invalidateViews();

}

The problem is that I still can’t find a way to call this method from the CategoryAdapter. Ive created an inner class that implements OnClickListener, and in public void onClick(View v) I’m trying to call that fragment’s method updateRightGrid(). I have access to the context through the variable mContext, but that doesn’t seem to help.

Any help would be much appreciated!

  • 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-18T08:16:16+00:00Added an answer on June 18, 2026 at 8:16 am

    You probably have context of your activity in your adapters, so you can make a method inside an activity like:

    //your activity code
    public void notifyItemAdapter() {
        itemAdapter.notifyDataSetChanged() ;
    }
    

    And then in your CategoryAdapter:

    //adapter code
    activityContext.notifyItemAdapter();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my android application Iam using viewpager.I have two fragments.Fragment1 and Fragment2.Iam calling two
I have a FragmentActivity using a ViewPager to serve several fragments. Each is a
I'm developing an Android 3.1 Tablet application using android.support.v4.view.ViewPager and android.support.v4.app.FragmentActivity . The following
I have ViewPager which I use to show zoomable images (using ImageViewTouch ). I
I have a ViewPager with three Fragments , each one shows a List (or
I am using a android.support.v4.view.ViewPager and wish to page through its views quickly. Currently,
I am using the android ViewPager : http://developer.android.com/reference/android/support/v4/view/ViewPager.html This class allows you to basically
I am using the ViewPager from the Android Support package (android.support.v4.view.ViewPager). My ViewPager layout
I am using fragments to show images/pages.I have one Activity(Main) which contains all the
I have the following problem. I have a tabbed application implemented using a ViewPager.

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.