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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:34:28+00:00 2026-06-08T07:34:28+00:00

A user selects an answer from a series of options in a listview. After

  • 0

A user selects an answer from a series of options in a listview. After submitting (right or wrong) I intend to highlight the correct answer in the list view.

I thought I had it figured:

 // get the position from the array we fed into the list view that has the correct answer    
int correct = curquestion.GetIndexOfCorrectAnswer();
// set that item's background to yellow
lView.getChildAt(correct).setBackgroundColor(Color.YELLOW);

I’ve discovered though through watching this run, and reading other people’s posts herem that getChildAt doesn’t provide a reliable result- sometimes it appears to pick a random child to set yellow. Any suggestions on other approaches?

  • 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-08T07:34:29+00:00Added an answer on June 8, 2026 at 7:34 am

    Enter position of list item at which you want to set color:

     adapter.setSelectedPosition(position);
     adapter.setNotifyOnChange(true);
     listView.invalidate();
    

    and in adapter class:

    // change the row color based on selected state

    if(selectedPos == position){
        label.setBackgroundColor(Color.YELLOW);
     }else{
        label.setBackgroundColor(Color.TRANSPARENT);
     }
    

    Hope this helps.

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

Sidebar

Related Questions

The user selects a state from a drop-down field, then ajax posts that value
Im making a simple Androidgame , where the user selects an answer to a
I have a checkbox list that each time the user selects one item, my
This query produces the right answer: SELECT users.*, SUM(overtime_list.shift_length) AS overtime_total, (SELECT GROUP_CONCAT(users_roles.role_ID) FROM
A user selects a portion of an image for a cut and paste operation.
When a user selects the remember me function, I save his username and id
Suppose a user selects a file in a dialogue box, and the app then
When a user selects a file, I want another file field to appear. It
Background story: when a user selects a portion of text in a text field
When a user selects an item to delete, I open an alertDialog to make

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.