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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:22:26+00:00 2026-05-18T07:22:26+00:00

I stumbled about a strange problem with ListViews. In the emulator the ListView shows

  • 0

I stumbled about a strange problem with ListViews.

In the emulator the ListView shows no feedback, when an item is pressed for selection. I think I have seen that in the real thing, but I am not sure. I would expect that the list item gets selected (darker background) when it is pressed, so that the user can see, which item he pressed.

Do I have to code that?

RG

After seeing the comments, I tried the following:

I created a file res/color/backgroundstate.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_selected="true"
          android:color="#888"/>
    <item android:state_pressed="true"
          android:color="#888"/>
    <item android:color="#eee"/>
</selector>

Then I use this in listitem.xml as a background color

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:textColor="@color/helptextcolor"
    android:background="@color/backgroundstate"
    android:padding="10dp"
    android:textSize="16sp" >
</TextView>

When I display the ListView with

    ArrayAdapter adapter=new ArrayAdapter<String>(this,R.layout.listitem,names);
    LV.setAdapter(adapter);
    LV.invalidate();

the program crashes.

There are three exceptions connected with this. But the problem seems to be the last one XMLPullParserException:

<item> tag needs a drawable.

Now?

  • 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-18T07:22:27+00:00Added an answer on May 18, 2026 at 7:22 am

    <item> indeed needs a drawable, not a color. You need a color drawable for that, like this:

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android">
      <solid android:color="#FFFF0000" />
    </shape>
    

    …and then put that into your item list.
    Furthermore, this is a drawable and as such, it has to be in a /res/drawable-* directory, not in the /res/color/ directory.

    To sum it up:

    • (optional) put your colors in the /res/values/color.xml file with a name
    • Create two shape drawables in xml, in the /res/drawable directory, one for the neutral color, one for the pressed color, in the fashion shown above
    • Create a state list drawable like you did, but in the /res/drawable directory
    • Use that as the background of your list item
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We stumbled upon a rather strange problem IMO. Our clients have been complaining about
I have been playing about with canvas, but have stumbled across a problem. When
Goodevening everyone, I stumbled on a rather strange problem today and I have no
I'm mucking about with jQuery AJAX and have stumbled upon an oddity (or rather
I am learning about LLDP protocol and have stumbled across terms chassis ID and
I have been curious about dynamically create class at runtime in C# and stumbled
here's a problem I just stumbled into: I have an php based web service
Recently, I have stumbled upon the basic understanding about PKI work-in-action process. I have
Working with expressjs for about a month by now I have stumbled across the
Today I stumbled about a Problem which seems to be a bug in the

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.