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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:13:38+00:00 2026-06-07T16:13:38+00:00

I have a horizontal view pager to page through 3 ListViews. The Three list

  • 0

I have a horizontal view pager to page through 3 ListViews. The Three list Views are populated from three different tables of a database. The problem is that the while I swipe through the page, the listview is not loading, instead it shows a white screen.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
            setContentView(R.layout.viewp);
    MyPagerAdapter adapter = new MyPagerAdapter();
    ViewPager myPager = (ViewPager) findViewById(R.id.threepageviewer);
    myPager.setAdapter(adapter);
    myPager.setCurrentItem(1);
}

private class MyPagerAdapter extends PagerAdapter {

    public int getCount() {
        return 3;
    }

    public Object instantiateItem(View collection, int position) {

        LayoutInflater inflater = (LayoutInflater) collection.getContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        int resId = 0;
        switch (position) {
        case 0:
            resId = R.layout.left;
            ListView list = new ListView(Listing.this);
            helper = new DbHelper(Listing.this);
            dataset_cursor1 = helper.getAll1();
            startManagingCursor(dataset_cursor1);
            adapter1 = new NoteAdapter(dataset_cursor1);
            list.setAdapter(adapter1);
            adapter1.notifyDataSetChanged();

            break;
        case 1:
            resId = R.layout.middle;
            ListView list1 = new ListView(Listing.this);
            helper = new DbHelper(Listing.this);
            dataset_cursor2 = helper.getAll();
            startManagingCursor(dataset_cursor2);
            adapter2 = new NoteAdapter(dataset_cursor2);
            list1.setAdapter(adapter2);
            adapter2.notifyDataSetChanged();
            break;
        case 2:
            resId = R.layout.right;
            ListView list2 = new ListView(Listing.this);
            helper = new DbHelper(Listing.this);
            dataset_cursor3 = helper.getAll2();
            startManagingCursor(dataset_cursor3);
            adapter3 = new NoteAdapter(dataset_cursor3);
            list2.setAdapter(adapter3);
            adapter3.notifyDataSetChanged();

            break;
        }

        View view = inflater.inflate(resId, null);

        ((ViewPager) collection).addView(view, 0);

        return view;
    }

    @Override
    public void destroyItem(View arg0, int arg1, Object arg2) {
        ((ViewPager) arg0).removeView((View) arg2);

    }

    @Override
    public void finishUpdate(View arg0) {

    }

    @Override
    public boolean isViewFromObject(View arg0, Object arg1) {
        return arg0 == ((View) arg1);

    }

    @Override
    public void restoreState(Parcelable arg0, ClassLoader arg1) {

    }

    @Override
    public Parcelable saveState() {
        return null;
    }

    @Override
    public void startUpdate(View arg0) {

    }

    public int getItemPosition(Object object) {
        return POSITION_NONE;
    }
}

What could be the problem here.

  • 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-07T16:13:40+00:00Added an answer on June 7, 2026 at 4:13 pm

    You are inflating the layout but you are not adding any views. You should do something like this:

    public Object instantiateItem(View collection, int position) {
    
            LayoutInflater inflater = (LayoutInflater) collection.getContext()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View view;
            switch (position) {
            case 0:
                view =  = inflater.inflate(R.layout.left, null);
                ListView list = (ListView) view.findViewById(R.id.listviewleft); //id of your listview
                helper = new DbHelper(Listing.this);
                dataset_cursor1 = helper.getAll1();
                startManagingCursor(dataset_cursor1);
                adapter1 = new NoteAdapter(dataset_cursor1);
                list.setAdapter(adapter1);
                adapter1.notifyDataSetChanged();
    
                break;   
                (...)
            }
    
    
        ((ViewPager) collection).addView(view);
    
        return view;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have implemented horizontal page view. One base page and three swipe pages. The
Do you know any controls inherited from the ItemsControl that have horizontal orientation of
I have a horizontal menu on a page like this <link rel=stylesheet type=text/css href=/classified/siteassets/css/mymenu.css
I have a horizontal unordered list I want to center horizontally in a div
I have a horizontal list (for a nav bar) and i want an individual
I have a horizontal list on which I have placed borders on the li
I have a ASP.Net web page with a grid view. I want to filter
My Case: I have original Page Control app from Apple. I would like to
I have the following ItemsControl page... <Page x:Class=Kiosk.View.ItemListView xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006 xmlns:d=http://schemas.microsoft.com/expression/blend/2008 xmlns:Converter=clr-namespace:Kiosk.Converter mc:Ignorable=d
I am Implementing a custom Horizontal View Pager. My Intention is to populate the

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.