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 have a rather simple ListView row: <?xml version=1.0 encoding=utf-8?> <RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=fill_parent android:layout_height=wrap_content
I have created an xml file like this: <?xml version=1.0 encoding=utf-8?> <ListView xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=match_parent
enter code here I have a ListView that have a different Layout XML for
In my XML, I have the following <ListView android:id=@android:id/list android:layout_width=match_parent android:layout_height=fill_parent > </ListView> How
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 and in my list item layout I am wanting to
I have a ListView with a custom layout for the rows (list items) and
I have a listView with custom objects defined by the xml-layout below. I want
I have a listview : <ListView android:clickable=true android:id=@android:id/list android:layout_width=match_parent android:layout_height=wrap_content > </ListView> the elements
I have a ListView ( my_list.xml ): <ListView android:id=@+id/my_list android:layout_width=wrap_content android:layout_height=wrap_content android:choiceMode=singleChoice /> The

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.