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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:50:44+00:00 2026-06-11T05:50:44+00:00

When looking through the list of the given position is not correct. How to

  • 0

When looking through the list of the given position is not correct. How to convey that I needed the position?
method getItemId(position) did not help!
There is some sample code:

lv1 = (ListView) findViewById(R.id.list);
inputSearch = (EditText) findViewById(R.id.inputSearch);
final String listcode[] = getResources().getStringArray(R.array.list);
adapter = new ArrayAdapter<String>(this, R.layout.list_item,
        R.id.product_name, listcode);

lv1.setAdapter(adapter);
lv1.setTextFilterEnabled(true);

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

        long line = adapter.getItemId(position);
        Integer itemname = new Integer((int) line);
        Intent intent = new Intent();
        intent.setClass(Main.this, ShowKnot.class);
        Bundle b = new Bundle();
        b.putString("defStrID", itemname.toString());
        b.putString("defStrName", listcode[itemname]);
        intent.putExtras(b);
        startActivity(intent);
    }
});
inputSearch.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence cs, int arg1, int arg2,
        int arg3) {         
    Main.this.adapter.getFilter().filter(cs);
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1,
        int arg2, int arg3) {
    // TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable arg0) {
    // TODO Auto-generated method stub
}
});
  • 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-11T05:50:46+00:00Added an answer on June 11, 2026 at 5:50 am

    Instead of

    long line = adapter.getItemId(position);
    

    you can use “position” in the method arguement returns the list item position number

     public void onItemClick(AdapterView<?> a, View v, int position,
            long id) {    
    
            a.getItemAtPosition(position);
    

    here “int position” parameter is the index of the listitem.

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

Sidebar

Related Questions

I was looking for a function to loop through a list of lists that
Looking through a few SQL implementations, I noticed that most DBMSs support defining an
Looking through the documentation for CFDataRef I can't see anything that will compress a
I'm looking through the documentation, trying to figure out if there is a way
Given a list of n distinct items, how can I step through each permutation
I'm looking for somewhere that has a list of all XML tags, with their
I have a List<List<int>> in F#. I need to iterate through it looking for
I am looping through a list for a spellchecker in vb.net (using vs 2010).
I am looping through a list of samaccountnames and performing several actions: # Disabling
I'm looping through a List of elements with foreach, like this: foreach (Type name

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.