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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:18:31+00:00 2026-05-15T18:18:31+00:00

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

  • 0
gridview.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            Toast.makeText(HelloGridView.this, "" + position, Toast.LENGTH_SHORT).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-05-15T18:18:32+00:00Added an answer on May 15, 2026 at 6:18 pm

    The <?> indicates a Generic. Read more about them here.

    Here is what the documentation says about the parameters:

    onItemClick(AdapterView<?> parent, View view, int position, long id)

    parent The AdapterView where the click happened.

    view The view within the AdapterView that was clicked (this will be a view provided by the adapter)

    position The position of the view in the adapter.

    id The row id of the item that was clicked.

    The AdapterView could be a ListView, GridView, Spinner, etc. The question mark inside the angle brackets indicates that it could be any of them. This is called generics in Java. You can use parent in code to do something to the whole view. For example, if you were using a ListView you could hide the whole ListView by the following line of code:

    parent.setVisibility(View.GONE);
    

    The View refers to a specific item within the AdapterView. In a ListView it is the row. Thus, you can get a reference to a TextView within a row by saying something like this:

    TextView myTextView = (TextView) view.findViewById(R.id.textView1);
    String text = myTextView.getText().toString();
    

    The position is the position of the view in the parent. For a ListView, it is the row number. The top row is position 0, the second row is position 1, the third row is position 2, etc. Note that if your ListView has a header view (like if you did ListView.addHeaderView(View)) then the header view would be position 0 and the actual rows would start their numbering at 1.

    Sometimes id is the same as position and sometimes it is different. If you are using an ArrayAdapter or SimpleAdapter then they are the same (except in the case that there is a header view and then they are off by one). For a CursorAdapter (and consequently a SimpleCursorAdapter) the id returns the row id of the table, that is, _id.

    Here are a few other good answers on this topic:

    • https://stackoverflow.com/a/9863279/3681880
    • https://stackoverflow.com/a/12966006/3681880
    • https://stackoverflow.com/a/24531354/3681880
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to java and android. i don't understand this code gridview.setOnItemClickListener(new OnItemClickListener() {
This is my gridview.java class public class TextGridActivity extends Activity { String[] _cataId=new String[100]
I currently have a gridview that returns an images position/id to a parent activity.
my line in gridview <asp:Label ID=Label2 runat=server Text='<%# new System.Text.StringBuilder(<a href=\/Administration/Pages/EditPage/?pageID=).Append(Eval(PageID)).Append(\>).Append(Eval(Name)).Append(</a>).ToString() %>'></asp:Label> fails with
How can I get a grid-view 's item tag by its position and have
I have a gridview which I am inflating in a Dialog view. Now when
Here is my code in my Activity: public class GridViewActivity extends Activity { GridView
GridView <asp:GridView ID=GridView1 runat=server AllowPaging=True AllowSorting=True PagerSettings-Position=TopAndBottom PagerSettings-Mode=Numeric PageSize=40 CellPadding=4 DataSourceID=dsEquipmentGridView ForeColor=#333333 GridLines=Horizontal Style=font-size:
GridView CurrentGrid =Grd_UserList; Grd_UserList.Columns.Clear(); ı have got this example, ı use Columns.Clear(); fonc. with
In gridview's column i have a linkbutton and a label under it. I want

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.