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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:22:49+00:00 2026-06-17T05:22:49+00:00

In my activity i have created seven listviews and am using viewpager to swipe

  • 0

In my activity i have created seven listviews and am using viewpager to swipe between them in the same activity. I then have a sqlite database populating each listview. My problem is the onitemclicklistener is not working, there are no errors and the code executes fine but nothing happens on list item clicks. I tested it out by adding toast display messages etc but nothing happens on list item clicks.

I suspect the problem is i have not gotten the listviews from xml layouts like the conventional method so the itemclicklistener method is slightly different, however i don’t know what method to use when utilising listviews this way and no other OS threads that i’ve seen creates listviews this way.
If anyone could please shed some light i’d be very grateful. Thanks in advanced.

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        mContext = this;
        setContentView(R.layout.activity_schedule);

        ListView listview1 = new ListView(mContext);
        ListView listview2 = new ListView(mContext);
        ListView listview3 = new ListView(mContext);
        ListView listview4 = new ListView(mContext);
        ListView listview5 = new ListView(mContext);
        ListView listview6 = new ListView(mContext);
        ListView listview7 = new ListView(mContext);


        Vector<View> pages = new Vector<View>();

        pages.add(listview1);
        pages.add(listview2);
        pages.add(listview3);
        pages.add(listview4);
        pages.add(listview5);
        pages.add(listview6);
        pages.add(listview7);

        ViewPager vp = (ViewPager) findViewById(R.id.viewpager);
        PageAdapter adapter = new PageAdapter(mContext,pages);
        vp.setAdapter(adapter);


        db.open();
        scheduleAdapter = new ScheduleAdapter(ScheduleActivity.this, db.getMonday(),CursorAdapter.NO_SELECTION );
        listview1.setAdapter(scheduleAdapter);      
        db.close();

        db.open();
        scheduleAdapter = new ScheduleAdapter(ScheduleActivity.this, db.getTuesday(),CursorAdapter.NO_SELECTION );
        listview2.setAdapter(scheduleAdapter);      
        db.close();

        db.open();
        scheduleAdapter = new ScheduleAdapter(ScheduleActivity.this, db.getWednesday(),CursorAdapter.NO_SELECTION );
        listview3.setAdapter(scheduleAdapter);      
        db.close();

        db.open();
        scheduleAdapter = new ScheduleAdapter(ScheduleActivity.this, db.getThursday(),CursorAdapter.NO_SELECTION );
        listview4.setAdapter(scheduleAdapter);      
        db.close();

        db.open();
        scheduleAdapter = new ScheduleAdapter(ScheduleActivity.this, db.getFriday(),CursorAdapter.NO_SELECTION );
        listview5.setAdapter(scheduleAdapter);      
        db.close();

        db.open();
        scheduleAdapter = new ScheduleAdapter(ScheduleActivity.this, db.getSaturday(),CursorAdapter.NO_SELECTION );
        listview6.setAdapter(scheduleAdapter);      
        db.close();

        db.open();
        scheduleAdapter = new ScheduleAdapter(ScheduleActivity.this, db.getSunday(),CursorAdapter.NO_SELECTION );
        listview7.setAdapter(scheduleAdapter);      
        db.close();

         listview1.setOnItemClickListener(new ListView.OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) { 

                }
        });
  • 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-17T05:22:50+00:00Added an answer on June 17, 2026 at 5:22 am

    From your describe I understand that the lists are showed up when you start the application.

    The position parameter, holds where the user clicked on the (screen) – list.

    Did you try to use it with switch case?

    I mean like this:

    list.setOnItemClickListener(new OnItemClickListener(){
                      public void onItemClick( AdapterView <?> parent, View view, int   
                                               position,long id){
    
                           switch(position){
                                case 0:
                               // write what you need here when the user clicks on the first list item
                                  break;
                                case 1:
                               // write what you need here when the user clicks on the 2nd list item 
                                   break;
                           }
                      }
                   };
    

    hope this will help you

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

Sidebar

Related Questions

I have created an Activity that will behave like a popup menu is actually
I have created an activity which sends a number of notifications to status bar.
I have created an activity called viewActivity. It displays the shared files and folders
I have created an activity implementing on touch listener and onclick listener . Both
I have created a custom workflow activity that copies attachments from a case to
I have created one class as public class FormActivity extends Activity { TextView tv
Assume that i have created a client TCP Socket in Activity A. I want
I am trying to display ListView . I have created one activity , in
I have an Activity that should only get created once. That is, onCreate can
I have an application and every new created activity will start an async task

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.