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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:27:22+00:00 2026-05-25T15:27:22+00:00

I have a listview which is customized to display an image and 2 textview.

  • 0

I have a listview which is customized to display an image and 2 textview. I just simply wanted to highlight one of the item from my list.

Firstly, I go with setSelection method of listview which i finally found out it is not the way as it is not working in touch mode.

So, I do some searching and found that I’d need to use setItemChecked method. Thus, I make a state-list color.

<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_checked="true" android:drawable="@color/checkbox_bg_fcs" />
    <item android:drawable="@color/WHITE" />
</selector>

I used it to set background color of my customized list item.

From List activity, I call setItemChecked(position,true) to a specific index of my listview.

Unfortunately, it doesn’t seem to work for me. Is there anything missing? Anyone got luck with it?

Note**, I did retrieve data for list view from network. I do setItemChecked only after i have data in my listview.
My listview is in single choice mode too.

  • 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-05-25T15:27:23+00:00Added an answer on May 25, 2026 at 3:27 pm

    I’m afraid that it is no easy way to do that in the Android Framework.

    In order to get the setSelection(…) working, your View has to implement the follogin interface: android.widget.Checkable

    You probably are using a some layout for View (an image and 2 textview in a LinearLayout maybe?), which doesn’t implement the Checkable interface.

    What you can do, is to create a custom View class which implements Checkable.

    Check out the link below for a checkable LinearLayout:

    http://tokudu.com/2010/android-checkable-linear-layout/


    If you want to change the background, than rewrite the setChecked method to do what you want.
    Very simple example:

    @Override
    public void setChecked(boolean checked) {
        if (checked) {
            this.setBackgroundColor(Color.RED);
        } else {
            setBackgroundColor(Color.BLACK);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a listview which displays items retrieved from the webpage. Each item in
I have used a customized list view in which i have added 4 TextView
I have ListView which shows images from an ImageList. Now wanted to get index
I have ListView which as one TextView in each Row. and im discovering some
I have a ListView which is using a GridView to display a DataTable and
I have a listview which includes 2 textviews and 1 imageview. Now, the image
I have listView in which I inflate a row contain textview and button now
I have a listView which defined like this in xml: <ListView android:id=@android:id/list android:layout_width=match_parent android:layout_height=match_parent
I have a following problem. I have a ListView which returns data from SQL
I have a listview NoteList which contains a method doListRefresh() to select list contents

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.