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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:20:07+00:00 2026-05-25T02:20:07+00:00

I have a LinearLayout : <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=match_parent android:layout_height=wrap_content style=@style/activated_item/> with style/activated_item: <style name=activated_item

  • 0

I have a LinearLayout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent" android:layout_height="wrap_content"
    style="@style/activated_item"/>

with style/activated_item:

<style name="activated_item" parent="android:Theme.Holo">
        <item name="android:background">@drawable/item_light_list</item>
    </style>

where drawable/items_light_list:

    <selector xmlns:android="http://schemas.android.com/apk/res/android"
        android:exitFadeDuration="@android:integer/config_mediumAnimTime">
         <item android:state_activated="true" android:drawable="@drawable/list_activated_holo"></item>
<item android:state_selected="true" android:drawable="@drawable/list_selected_holo_light"></item>
        <item android:drawable="@drawable/list_selected_holo_light"></item> <!-- If I would remove this line the item will be selected after a long click -->
    </selector>

The mentioned LinearLayout is used for inflating in ‘view’ to be used as an item(s) in ListFragment. I need the android:background value to be changed after a longpress on the item. I tried to do:

public boolean onItemLongClick(AdapterView<?> parent, View view,
                    int position, long id) {
                view.setSelected(true);
return true;

But this didn’t work.

Please advice what shall I do and how to change my drawable resourse in order to set a different background color after a longclick.

EDIT:

If I remove <item android:drawable="@drawable/list_selected_holo_light"></item> everything is working, but this is not a workaround for me.

  • 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-25T02:20:07+00:00Added an answer on May 25, 2026 at 2:20 am

    Have you tried View.setBackgroundColor(int)?

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

Sidebar

Related Questions

Here's a layout: <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=wrap_content android:orientation=vertical> <RelativeLayout android:id=@+id/first_tv_container android:layout_width=fill_parent android:layout_height=wrap_content android:focusable=true android:background=@android:drawable/list_selector_background>
I have following layout in my android application. <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:id=@+id/mainlayout android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent
I have a listactivity with the following layout-xml <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent
I have the following layout in place <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=vertical android:layout_width=fill_parent
I have a simple LinearLayout in Android with two images vertically: <?xml version=1.0 encoding=utf-8?>
I have in my application 2 views: a. res/layout/main.xml - a standard view with
I have a vertically oriented LinearLayout that has a child LinearLayout that includes a
I have a adView in my application UI i don't want to display it
I have an Activity in my app that simply displays some results from a
Using Google's Hello TabWidget tutorial found here I was able to build a tabWidget

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.