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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:26:30+00:00 2026-06-10T18:26:30+00:00

My Custom ListView Adapter class like this. I want to get the index number

  • 0

My Custom ListView Adapter class like this.
I want to get the index number of an item once an item has been pressed(onclick). How can I get the index number and pass it to a int.. The code where I’ll get the index number is after the onCreate method. Please help me!

// On holder.txtstormName_Nice button click i want to get selected item index.
public class ListViewCustomAlerts extends BaseAdapter {

    ArrayList<HurricaneBeanClass> itemList;

    public Activity context;
    public LayoutInflater inflater;
    public ListViewCustomAlerts(Activity context,ArrayList<HurricaneBeanClass> arraylist_List) 
    {
        super();
        this.context = context;
        this.itemList = arraylist_List;
        this.inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }
    @Override
    public int getCount() 
    {
        return itemList.size();
    }

    @Override
    public Object getItem(int position) 
    {
        return itemList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
         p =position;
       final ViewHolder holder;
        if(convertView==null)
        {
            holder = new ViewHolder();
            convertView = inflater.inflate(R.layout.hurricane_row, null);  
            holder.txtstormName_Nice=(TextView)convertView.findViewById(R.id.hurricaneNameRowTextView);
            convertView.setTag(holder);  

        }
        else
            holder=(ViewHolder)convertView.getTag();
        HurricaneBeanClass bean = (HurricaneBeanClass) itemList.get(position);
        holder.txtstormName_Nice.setText(bean.getStormName_Nice());

        holder.txtstormName_Nice.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
        //here i want item index.................
                HurricaneBeanClass bean = (HurricaneBeanClass) itemList.get(position);
                HurricaneActivity.curlat=bean.getCurentlat();
                HurricaneActivity.curlon=bean.getCurentlon();

...

            }
        });

        return convertView;

    }                  

}

public static class ViewHolder
{
    TextView txtstormName_Nice;
}
  • 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-10T18:26:32+00:00Added an answer on June 10, 2026 at 6:26 pm

    In getView() method you can get it

     public View getView(final int position, View convertView, ViewGroup parent) {
     .........
     .....
    
      System.out.println("Index:"+position);
     }
    

    So, here position is your index

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

Sidebar

Related Questions

I have a custom adapter for my ListView which has multiple TextViews. I want
Iv'e got a custom Listview implemented in this particular class, it looks like [Image/Textview/Checkbox]
I have a listview connected to a custom array adapter. This list shows information
I am attempting to create a custom Adapter for my ListView since each item
I have a custom listView. The main layout xml is something like this: <?xml
I'm trying to make listView with custom adapter and multiselection. My adapter looks like
I have a custom ListView adapter which implements an ImageThreadLoader class. Unfortunately, the class
I have a custom ListView adapter which implements an ImageThreadLoader class. Unfortunately the class
I use a custom list adapter and ArrayList for my ListView. This solution was
I have a custom adapter populating a listview. Each row has a checkbox which

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.