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

Today I stumbled about a Problem which seems to be a bug in the
Recently, I have stumbled upon the basic understanding about PKI work-in-action process. I have
I've stumbled across this great post about validating parameters in C#, and now I
I recently stumbled across this entry in the google testing blog about guidelines for
I was thinking earlier today about an idea for a small game and stumbled
I stumbled over this passage in the Django tutorial : Django models have a
I have stumbled into several methods of looping in JavaScript, what I like the
I was writing some commented PHP classes and I stumbled upon a problem. My
I've stumbled upon a rather strange issue today with Spring 3.0: There's an abstract
This is a strange one... In a windows forms app (VB.NET/VS 2005) I have

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.