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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:56:23+00:00 2026-06-10T01:56:23+00:00

I am working on an android application. I have created a listview by using

  • 0

I am working on an android application. I have created a listview by using

setListAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,arrayname));   
getListView().setTextFilterEnabled(true);   

Now i want to change the selected item’s color. I could change the background of the selected item by placing

listviewobject.getChildAt(position).setBackgroundColor(Color.BLACK);

in onListItemClick()

this code is changing the background color but if I select any other list item then also the previously clicked list item’s color is red.So I change the previously clicked listitem’s color by

l.getChildAt(prevpos).setBackgroundColor(Color.BLACK);

now the problem is if i change the background of previously clicked listitems color to black.Then i can’t see the text on that particular listitem.I i click again then only i can see the text on that item.So its look weired.please help me friends

  • 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-10T01:56:24+00:00Added an answer on June 10, 2026 at 1:56 am

    After going through lots of posts and blogs i found this solution it works for me…

    declare row variable global

    public View row;
    
    your_list.setOnItemClickListener(new OnItemClickListener() {
    
        public void onItemClick(AdapterView<?> a, View v,
                            int position, long id) {
    
        if (row != null) {
            row.setBackgroundResource(R.color.orange);
        }
        row = v;
        v.setBackgroundResource(R.color.transparent_green);
    )};
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello i have created a sample application in android using eclipse IDE my code
I am developing an android application and have created a tabbed layout for my
I have created an application in Android for RabbitMQ using RabbitMQ-Android tutorial. It is
I am working on Android Application. Now I have requirement of search the entered
My Android application was working in English and I have to provide the users
I have an android application and web-server working together. Now I want user log
I have integrated Zxing library in my Android application, and it is Perfectly working,
I am working on a Mapview in my android application, in which i have
I am working on an application for android and we since we have lots
I am working on an android application and I added a xml layout file

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.