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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:54:53+00:00 2026-05-22T01:54:53+00:00

WARNING: The XML in this question is wrong, read the answer before you confuse

  • 0

WARNING: The XML in this question is wrong, read the answer before you confuse yourself!


I have been banging my head on the wall for a while now. The following posts have shed light on the subject, but failed to solve my issue: Android ListView State List not showing default item background and ListView item background via custom selector

The proper nine-patch background shows perfectly when I select the list item, but I can not get the default nine-patch background to show initially. It seems to me that I need to set the default item background somehow, but I can’t figure out how to do so.

List View:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical">
  <TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/shopListHeader"
    />
  <ListView
    android:id="@+id/shopList"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:dividerHeight="0px"
    android:divider="#FFFFFFFF"
    android:listSelector="@drawable/shop_list_selector"
    />
</LinearLayout>

Selector:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
  android:visible="true">

    <!-- the list items are enabled and being pressed -->
    <item
        android:state_pressed="true"
        android:drawable="@drawable/shop_list_item_pressed" />

    <item
        android:state_selected="true"
        android:textColor="#FFFFFFFF" />
</selector>

Background:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
  android:visible="true">

    <item
      android:state_selected="true"
      android:drawable="@android:color/transparent" />

    <item
        android:drawable="@drawable/shop_list_item" />
</selector>

As you can see, I have dumbed down the examples from the references.

You may also notice that the Background selector isn’t being referenced anywhere. I started tossing it in random places (if the app compiled the addition either had no effect or cause a forced close)

I have also made an attempt to stop the color of the text from changing to black and grey when an item is selected but not pressed (can be done by scrolling through the list). Since my background will be black in the center, the text becomes partially invisible when selected. That addition (the last item node in the Selector) does nothing, as far as I can tell.

Does anyone have any thoughts on getting this ridiculously time consuming functionality working?

  • 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-22T01:54:54+00:00Added an answer on May 22, 2026 at 1:54 am

    I was gonna delete this thread, but I can’t so I’ll see if I can’t use this as an example of what not to do 🙂

    First, in the ListView XML: android:listSelector="@drawable/shop_list_selector"
    Don’t do that!

    What I was trying to do here was set the background of the list items and the android:background property didn’t work. You may have noticed that the item XML is missing, and that is because it was missing from my head! (I never touched it over the countless hours I was hammering away at this ‘issue’) So the line android:background="@drawable/shop_list_selector" goes in the item’s properties and everything is groovy. (Remember the XML above is very wrong so don’t use it!)

    …Well except that it doesn’t look as good in real life as it did in my head 🙁
    Back to the drawing board!!!

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

Sidebar

Related Questions

Good morning. I have an XML file which contains lists of warning and errors
Warning - I am very new to NHibernate. I know this question seems simple
WARNING: I have been learning Python for all of 10 minutes so apologies for
This question is in continuation of this post , I have tried installing Xerces-C
I have an XML feed that looks like this: <?xml version=1.0 encoding=UTF-8?> <productFeed version=1.0
first of all, I have a .NET 4.0 application with this configuration: <?xml version=1.0?>
I have a VS2008 solution using xml documentation, and we have warnings as errors
(Warning - asp newbie) I have an aspx file with the tag <%@ Page
First of all, I am a WEB NOOB. Which probably explains this question. Anyway,
I have the need to parse partial XML fragments (which are presented as std::string),

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.