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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:54:04+00:00 2026-06-04T23:54:04+00:00

I am kind of new to Android, I started working with SQLite 3 days

  • 0

I am kind of new to Android, I started working with SQLite 3 days ago. I managed to populate a list from database and defined some views following The Pragmatic Programmers – Hello Android, but I have a problem: when the list is displayed and I want to select an item it only highlights a line below and above the entry in the list. I am sure it has to do something with the definition of the lists row xml or listview xml. Though I will post the entire code.

validations_list.xml

<?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">
<TextView
android:id="@+id/l_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/l_idcolon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=": "
 />
<TextView
android:id="@+id/l_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
 />
<TextView
android:id="@+id/L_namecolon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=": "
/>
<TextView
android:id="@+id/av"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:singleLine="true"
android:textStyle="italic"
 />
</LinearLayout>

testing.xml

<?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"
>
<!-- Note built-in ids for 'list' and 'empty' -->
<ListView
android:id="@android:id/list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:id="@android:id/empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/empty" />
</LinearLayout>

And here is the code for my activity:

public class LinesListActivity extends ListActivity {

private static final String TAG = "ValidationsListActivity";
private static int [] TO = {R.id.l_id,R.id.l_name,R.id.av};


private DbManipulator dbm;

@Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.testing);

    dbm = new DbManipulator(this);
    try
    {

        Cursor c = dbm.getLines();
        startManagingCursor(c);
        showEvents(c);
    }
    finally
    {

    }
}

private void showEvents(Cursor c) {

    SimpleCursorAdapter adapter = new   SimpleCursorAdapter(this,R.layout.validations_list,c,FROM_V,TO);
    setListAdapter(adapter);

}


@Override
public void onPause()
{
    super.onPause();
    dbm.close();
}
}

And I have a style defined for my app, but when I change it back to normal style the problem stays, nothing actually changes.

  • 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-04T23:54:06+00:00Added an answer on June 4, 2026 at 11:54 pm

    The selector defaults to showing behind the list which defaults to transparent, so you can see the selector through it.

    You have set an opaque color for the background, so you need to set the selector on top.

    Add this to your listview XML

    android:drawSelectorOnTop="true"
    

    That should fix it up.

    EDIT

    Ok, next trick. Set up a color state selector.

    1) Create a color list in your values folder, setting color names to their hex numbers:

    colors.xml

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <color name="white">#ffffff</color>
        <color name="blue">#2554C7</color>
        <color name="green">#347C2C</color>
    </resources>
    

    2) Create a selector in your drawable folder:

    item_selector.xml

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item 
         android:state_pressed="true" 
         android:drawable="@color/green" />
    </selector>
    

    3) Finally, set the selector as the background of your list row elements:

    android:background="@drawable/item_selector"
    

    Using the above would cause the background of the list item you were pressing to turn green while pressed, leaving the text visible on top.

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

Sidebar

Related Questions

Im new to android and I want to create kind of CRUD with SQLite.
I'm kind of new to Android programming, and i'm comming from a strong background
I'm breaking my head over this one. I'm kind of new in android development.
I am kind of new to C (I have prior Java, C#, and some
I'm kind of new to this whole thing so I need some help. I
I am developing an app for android where I need some data from a
I'm kind of new to android programming and I've been searching for an answer
I just started make a kind of Android hybrid app, an application with WebView.
Im kind of new to Android. I am playing around with the Android FingerPaint
I a new to Android development, so this is kind of a basic question.

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.