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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:50:17+00:00 2026-06-04T20:50:17+00:00

I have a ViewPager that uses ListFragments on each page. I implement onListItemClick and

  • 0

I have a ViewPager that uses ListFragments on each page. I implement onListItemClick and onContextItemSelected to handle list item click and long clock, respectively. The ListFragment data is loaded via AsyncTask from the internet.

The desired behavior is to short press on a list view item to start a detail activity to show detail for that location (it’s a weather app). When the user long presses, a context menu pops up to give the user other options, including to view raw data.

The short press and detail activity works fine. the problem is the long press, context menu. When the user is on page 3 and selects the 2nd item in the list using a long press, and then selects “show raw data” for that location, the raw data for the 2nd item on page 2 is shown, not page 3.

Right now I’m using setOffscreenPageLimit(1). when I change that to setOffscreenPageLimit(2), the data from page 1 is displayed instead of page 3.

Code:

@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case R.id.cmenu_showRaw:    

        ViewGroup dataPanel = (ViewGroup) myListView.getChildAt(info.position);         
        TextView tvRaw = (TextView) dataPanel.findViewById(R.id.textRaw);
        TextView tvLocationID = (TextView) dataPanel.findViewById(R.id.textLocationId);

        showDismissDialog(tvRaw.getText().toString(), tvLocationID .getText().toString()); 
        return true;

I’m trying to figure out why the raw and locationID data are not pulled from the fragment that is currently shown on the ViewPager, but from the offset page. I’m still learning Fragments, so I’m probably missing something subtle.

  • 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-04T20:50:20+00:00Added an answer on June 4, 2026 at 8:50 pm

    I figured it out: info.targetView gets me the view that I longpressed on. From there I can do a findViewById to get what I need.

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

Sidebar

Related Questions

I am using a ViewPager with a custom PagerFragmentAdapter that uses an internal list
I have an app that uses ActionBarSherlock to provide a ViewPager control for tab
My app uses the android.support.v4.view.ViewPager class. For each page in the ViewPager, I want
I have a ViewPager FragmentActivity that holds 3 tabs, Each one of the tabs
Hi, I have created an app that uses ViewPager and all pages contain WebViews.
I have created an android app that uses a ViewPager to swipe through three
I have a ViewPager with a dynamic number of pages in it. Each of
I have a FragmentActivity using a ViewPager to serve several fragments. Each is a
I have a ViewPager that loads images from a remote server. My problem is,
I'm trying to create a ViewPager that takes up the entire screen. Inside each

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.