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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:04:25+00:00 2026-05-25T03:04:25+00:00

I have a ListView in my layout. Here is the layout for list item.

  • 0

I have a ListView in my layout. Here is the layout for list item.

shopitem.xml

<?xml version="1.0" encoding="utf-8"?>
<TwoLineListItem xmlns:android="http://schemas.android.com/apk/res/android" 
    android:paddingTop="2dip"
    android:paddingBottom="2dip"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:mode="twoLine"> 
    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/text1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:paddingTop="6dip"
        android:paddingLeft="44dip"
        android:textStyle="bold" 
        android:lines="1"
        android:textColor="#FFFFFF"/>
    <ImageView
            android:id="@+id/playBtn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="3dip"
            android:layout_alignRight="@android:id/text1"
            android:src="@drawable/btnplaypreview"/>            
</TwoLineListItem>

Now I want to set some change of image in playBtn OnItemClickListener. For that I am using the following code.

ListView shopActivityListView = (ListView) findViewById(R.id.shopActivityListView);
shopActivityListView.setCacheColorHint(Color.TRANSPARENT);
shopActivityListView.setAdapter(new ArrayAdapter<String>(getApplicationContext(), R.layout.shopitem, trackArr[1]));

shopActivityListView.setOnItemClickListener(new OnItemClickListener() {

@Override
public void onItemClick(AdapterView<?> parent, View vItem, int position, long id) {
    // TODO Auto-generated method stub
    ImageView playBtn = (ImageView) vItem.findViewById(R.id.playBtn);
    playBtn.setImageResource(R.drawable.eq12);
}                
});

But nothing is happening on itemclick. I have checked that onItemClick method is executing without any exception. But nothing is changing. What is the problem in my code?

  • 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-25T03:04:25+00:00Added an answer on May 25, 2026 at 3:04 am

    The image in any item of Listview cannot change directly as it is controlled by Adapter. Only getView() method of the adapter can set any view in the items.
    Therefore, in onItemClick method, we have to set a position specific flag and then call the notifyDataSetChanged() for the adapter. Moreover, a custom adapter is needed, where we have to define the getView() method so that we have set the image depending on the above position specific flag.

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

Sidebar

Related Questions

I'm using a custom listview I found here: http://developer.android.com/resources/samples/ApiDemos/res/layout/linear_layout_9.html Seems to be valid in
I have a listView with custom objects defined by the xml-layout below. I want
I have a custom listView. The main layout xml is something like this: <?xml
I have a problem with listview which list item contain a checkbox. When i
I have a listview which is simply populated this way: setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_multiple_choice, aux))
I have a listview that needs to be multiple choice (i.e each list item
I have a listView, where each row has a button in the row layout.
I have a ListView on a page that displays a list of widgets. When
I have list item with EditText in it, I dont know how many items
I have an activity that extends ListView. I populate my list with the results

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.