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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:52:35+00:00 2026-06-12T18:52:35+00:00

I have a strange behaviour with the ViewImage in the ListView linked in a

  • 0

I have a strange behaviour with the ViewImage in the ListView linked in a ListActivity.

So, I have list activity for which the list is made of 3 text fields and one image.

 <TextView android:id="@+id/me_games_won"
     android:textSize="16sp"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"/>

<TextView android:id="@+id/gamesmate_username"
     android:textSize="16sp"
     android:textStyle="bold"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"/>

 <TextView android:id="@+id/him_games_won"
     android:textSize="16sp"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"/>

 <ImageView
    android:id="@+id/imageActionHomepage"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/im_completed" />
</LinearLayout>

My adapter looks at changing the image based on some criteria. I have the following code:

public View getView(int position, View convertView, ViewGroup parent) {
        // assign the view we are converting to a local variable

        View v;

        LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        v = inflater.inflate(R.layout.homepage_listitem, null);

        /*
         * Recall that the variable position is sent in as an argument to this method.
         * The variable simply refers to the position of the current object in the list. (The ArrayAdapter
         * iterates through the list we sent it)
         * 
         * Therefore, i refers to the current Item object.
         */
        JSONGame i = (JSONGame) objects.get(position);

        if (i != null) {
            // This is how you obtain a reference to the TextViews.
            // These TextViews are created in the XML files we defined.
            TextView tt = (TextView) v.findViewById(R.id.me_games_won);
            TextView ttd = (TextView) v.findViewById(R.id.gamesmate_username);
            TextView mt = (TextView) v.findViewById(R.id.him_games_won);
            ImageView iv = (ImageView) v.findViewById(R.id.imageActionHomepage);

            // check to see if each individual textview is null.
            // if not, assign some text!
            if (tt != null) {
                tt.setText(Long.toString(i.getScore()));
            }
            if (ttd != null) {
                ttd.setText(i.getGamemateUsername());
            }
            if (mt != null) {
                mt.setText(Long.toString(i.getGamemateScore()));
            }
            if (i.getAction().equals(JSONGame.GAME_NONE))
                iv.setImageResource(R.drawable.im_completed);
            else if (i.getAction().equals(JSONGame.GAME_ACCEPT)) {
                iv.setOnClickListener(new HomepageMenuAdapter(this.activity, position, R.drawable.im_accept));
                iv.setImageResource(R.drawable.im_accept);
            } else if (i.getAction().equals(JSONGame.GAME_WAITING))
                iv.setImageResource(R.drawable.im_awaiting);
            else
                iv.setOnClickListener(new HomepageMenuAdapter(this.activity, position, R.drawable.im_continue));
                iv.setImageResource(R.drawable.im_continue);
        }

        // the view must be returned to our activity
        return v;
    }

The images displayed in the list box are random but often equal to the last row. I inflating the row each time to make sure that a new instance of the row is created. The image displayed in not the one set up in the layout file.

Cheers.
David.

  • 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-12T18:52:36+00:00Added an answer on June 12, 2026 at 6:52 pm

    Looks like you are missing the braces for the last else segment:

        :
        } else if (i.getAction().equals(JSONGame.GAME_WAITING))
                iv.setImageResource(R.drawable.im_awaiting);
        else { // <-- missing
                iv.setOnClickListener(new HomepageMenuAdapter(this.activity, position, R.drawable.im_continue));
                iv.setImageResource(R.drawable.im_continue);
        } // <-- missing
        :
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a strange behaviour with the hook mechanism which i don't understand and
I am having a strange behaviour in a small WPF application. I have one
I have a strange behaviour with the code below: function update(txt, _) { #text
I have strange behaviour in Python/PyMongo. dbh = self.__connection__['test'] first = dbh['test_1'] second =
I know it's a simple question, but I have strange behaviour in here. <pre>
I have a strange behaviour. I am using a rather heavy page (4000 nodes)
I have very strange behaviour of Java Date class: System.out.println(new Date().toGMTString()); long l =
Why this two functions have the strange behaviour of when I click on thead,
I have a strange Hibernate behaviour in my program. I have two classes with
During my university exercise I have come across strange behaviour of a variable. /*

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.