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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:21:09+00:00 2026-06-14T00:21:09+00:00

When I click a row in my ListView the row is using the statelist

  • 0

When I click a row in my ListView the row is using the statelist but the individual elements are not.

  1. Setting duplicateParentState(true) on the image, text and image does nothing.
  2. Setting the individual items to clickable(true) applies the statelist changes to each item, but does not change the parent even if addChildStates() (approximation of methodname) is set.

So, I want to click a row in the ListView and have the states of the individual items updated. Obviously missing something.

I have the following row in a ListView:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/list_row"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:background="@drawable/statelist_row" >

    <FrameLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0.1" >

        <ImageView
            android:id="@+id/product_image"
            style="@style/list_image"
            android:contentDescription="@string/product_image" />

        <ProgressBar
            android:id="@+id/product_image_progress"
            style="@style/list_image"
            android:visibility="gone" />
    </FrameLayout>

    <TextView
        android:id="@+id/product_name"
        style="@style/list_text"
        android:layout_weight="0.9"
        android:gravity="center_vertical" />

    <ImageView
        style="@style/list_caret"
        android:layout_weight="0.1"
        android:contentDescription="@string/caret" />

</LinearLayout>

In the adapter I make the row clickable:

    holder.productListRow.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toast.makeText(context, "CLICKED: '" + holder.productName.getText().toString() + "'", Toast.LENGTH_LONG).show();
        }
    });

I have a statelist that is applied in the styles:

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

    <item android:drawable="@color/selected_item" android:state_pressed="true" android:textColor="@color/white" android:color="@color/white"/>
    <item android:drawable="@color/std_background" android:color="@color/black"/>

</selector>

From colors:

<color name="list_text_color">@drawable/statelist_produce_row</color>

Finally, from styles:

<style name="list_text" parent="fill_parent">
    <item name="android:textSize">@dimen/list_text_size</item>
    <item name="android:textColor">@color/list_text_color</item>
    <item name="android:layout_gravity">left|center_vertical</item>
    <item name="android:padding">@dimen/list_text_padding</item>
    <item name="android:textStyle">bold</item>
</style>
  • 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-14T00:21:10+00:00Added an answer on June 14, 2026 at 12:21 am

    Shouldn’t you make the listview items clickable by setting an onItemClickListener for the listview instead of making each row clickable?

    Try this

    mListView.setOnItemClickListener(new OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            ...
    }        
    });
    

    or if you’re extending the ListActivity, you can directly implement onListItemClick():

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know how to set up listview to highlight a row when you click
i write row click handler: $('#mTable tr').unbind().live('click', function() { //specialFunction() }); specialFunction must not
I have the following code that works great for row click, but I want
Adding the row one by one in the button click.. (i tried but its
I have created a custom listview using SimpleAdapter and in each row of list
I have a ListView in my Activity and for each row Im using my
I'm getting am AndroidRuntimeException when I click the menuButton using this custom ListView Adapter:
I have three textviews in a row of a listview using custom adapter and
I need to handle the selected row in listview on long click on the
I have a listview with each row containing some text and a delete button.

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.