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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:30:05+00:00 2026-06-17T15:30:05+00:00

I am creating a ListView dynamically inside of the adapter of a gridview. So

  • 0

I am creating a ListView dynamically inside of the adapter of a gridview. So what happens is, the gridview contains listviews in its cells. Inside of the gridview adapter, I create the listview with its own adapter. This works fine, however, I need to write a onitemclick listener for the listView to access the position of each of its items. Currently I am writing the onitemclick listener inside of the gridview adapter right after I have created the listview, however I am not sure how to gain access to the listview items.

Please help.

Here is the code where I create the listview, inside of the gridview adapter (getview method – I deleted the other irrelevant code):

 public View getView(int position,View convertView, ViewGroup parent)
 {
     ListView list;

        if (convertView == null)
        {  

              //if it's not recycled, initialize some attributes.  
              list = new ListView(mContext);
              list.setVerticalScrollBarEnabled(false);
              list.setLayoutParams(new GridView.LayoutParams(150, 550));
              list.setPadding(2,2,2,2);
              list.setAdapter(new Adapter_ListView_GridView_Calendar(mContext, dagtyeVanhaarkappers.get(position-hairdresserids.size()), gebookdeurUser.get(position-hairdresserids.size()), tekening.get(position-hairdresserids.size())));
        }  
        else
        {
         list = (ListView) convertView;
        }  

        list.setCacheColorHint(0);
        list.setId(position-hairdresserids.size());

        list.setOnTouchListener(new View.OnTouchListener()
              {

                  public boolean onTouch(View v, MotionEvent event)
                  {   
                // Disallow the touch request for parent scroll on touch of child view
                      v.getParent().requestDisallowInterceptTouchEvent(true);
                      return false;
                  }
              });

       final int itemp = position;
       final int dayId = parent.getChildCount();

       list.setOnItemClickListener( new OnItemClickListener()
       {


        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3)
             {
               // custom dialog
        final Dialog dialog = new Dialog(mContext);
        dialog.setContentView(R.layout.dialog_make_booking);

                    //NOT SURE HOW TO ACCESS LIST ITEM POSITION FROM HERE ???

        dialog.show();
             }
       });

        return list;
     }

EDIT:

This is what I tried now but I keep getting a value of 0…

 list.setOnItemClickListener( new OnItemClickListener()
       {


             public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3)
             {
               // custom dialog
        final Dialog dialog = new Dialog(mContext);
        dialog.setContentView(R.layout.dialog_make_booking);

                    //NOT SURE HOW TO ACCESS LIST ITEM POSITION FROM HERE ???

                    long l = list.getAdapter().getItemId(arg2); //THIS VALUE STAYS 0
                    String s = (String) String.valueOf(l);
        dialog.setTitle(s);

        dialog.show();
             }
       });
  • 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-17T15:30:06+00:00Added an answer on June 17, 2026 at 3:30 pm

    Make the listview member of the current class and arg2 is the position of the listitem that was clicked.

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

Sidebar

Related Questions

I've problem when creating a Horizontal Listview inside list view.. myAdapter adapter = new
I'm creating a ListView that contains two TextViews and an ImageView. I'm passing data
I am creating a ListView dynamically and want to add two TextViews in a
am working in windows application with c#.Am creating the listview items dynamically..i want to
I'm creating ListView in AsyncTask inside Fragment . In onActivityCreated method i call AsyncTask's
I've passes by this tutorial: Android: Creating and populating ListView items in XML I
First off, I am not dynamically creating any controls. This is the order I
Im creating a custom listview implementation. This is an instance of my view declaried
I'm working on creating a dictionary and I'm trying to create ListMenu dynamically as
I used the code below to create a TableRow with content dynamically. It works

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.