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

The Archive Base Latest Questions

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

This is my source code. getView shown wrong position. I already searched solution for

  • 0

This is my source code. getView shown wrong position. I already searched solution for that on google but no success. Please help me.

public View getView(final int position, View convertView,
        ViewGroup viewGroup) {
    final Phonebook entry = listPhonebook.get(position);
    if (convertView == null) {
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(R.layout.phone_row, null);
        convertView.setOnTouchListener(new OnTouchListener() {

            @Override
            public boolean onTouch(View mycurrentListItemView,
                    MotionEvent event) {

                int action = event.getAction();
                if (action == MotionEvent.ACTION_DOWN) {
                    Log.i("List item clicked position : ", "" + position);
                    Log.i("Name::Mail", "" + entry.getName() + " :: "
                            + entry.getMail());
                    mycurrentListItemView.setBackgroundColor(Color
                            .parseColor("#38ACEC"));
                } else if (action == MotionEvent.ACTION_UP
                        || action == MotionEvent.ACTION_CANCEL) {
                    mycurrentListItemView.setBackgroundColor(Color
                            .parseColor("#FFFFFF"));
                }
                return false;
            }
        });
  • 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-11T14:50:18+00:00Added an answer on June 11, 2026 at 2:50 pm

    ListView is recycling the views with the convertView, so it only sets up the onTouchListener the first time the views are created (because of if (convertView == null).

    If you want this solution to work, you have to move the convertView.setOnTouchListener() call outside of the if (convertView == null) condition.
    This way it will be initialized every time a view is displayed on the screen with your proper Phonebook entry.

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

Sidebar

Related Questions

If there's any open source code that does this already I'm interested in hearing
I have this source code from 2001 that I would like to compile. It
I am using vala. This is the source code that gives that compile time
I have a jar file that contains source code. How can I browse this
Suppose you have some source code that comes from the unix world. This source
What is wrong in this source code? #include <iostream> #include <ostream> #include <fstream> void
What is wrong with this source code? 1 package Core; 2 3 import java.sql.*;
I have this source code at the moment, but the issue I am having
I just saw this source code on a website, but I don't know what
I have this source code: idx=0 b=plt.psd(dOD[:,idx],Fs=self.fs,NFFT=512) B=np.zeros((2*len(self.Chan),len(b[0]))) B[idx,:]=20*log10(b[0]) c=plt.psd(dOD_filt[:,idx],Fs=self.fs,NFFT=512) C=np.zeros((2*len(self.Chan),len(b[0]))) C[idx,:]=20*log10(c[0]) for idx

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.