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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:45:50+00:00 2026-05-18T22:45:50+00:00

I have the following problem, and searched for a while but haven’t got any

  • 0

I have the following problem, and searched for a while but haven’t got any solution from the net:

I have a custom list view, each item has the following layout (I just post the essential):

<LinearLayout>
 <ImageView android:id="@+id/friendlist_iv_avatar" />
 <TextView andorid:id="@+id/friendlist_tv_nick_name" />
 <ImageView android:id="@+id/friendlist_iv_status_icon" />
</LinearLayout>

And I have a class FriendRowItem, which is inflated from the above layout:

public class FriendRowItem extends LinearLayout{

 private ImageView ivAvatar;
 private ImageView ivStatusIcon;
 private TextView tvNickName;

 public FriendRowItem(Context context) {
  super(context);
  RelativeLayout friendRow = (RelativeLayout) Helpers.inflate(context, R.layout.friendlist_row);
  this.addView(friendRow);
  ivAvatar = (ImageView)findViewById(R.id.friendlist_iv_avatar);
  ivStatusIcon = (ImageView)findViewById(R.id.friendlist_iv_status_icon);
  tvNickName = (TextView)findViewById(R.id.friendlist_tv_nick_name);

 }

 public void setPropeties(Friend friend) {
  //Avatar
  ivAvatar.setImageResource(friend.getAvatar().getDrawableResourceId());

  //Status
  Status.Type status  = friend.getStatusType();
  if ( status == Type.ONLINE) {
   ivStatusIcon.setImageResource(R.drawable.online_icon);
  } else {
   ivStatusIcon.setImageResource(R.drawable.offline_icon);
  }

  //Nickname
  String name = friend.getChatID();
  if ( friend.hasName()) {
   name = friend.getName();
  }
  tvNickName.setText(name);
 }

}

In the main activity, I have a custom listview: lvMainListView, with an custom adapter (whose class extends ArrayAdapter – and off course: override the method getView ), the data set of the adapter is: ArrayList<Friend> friends:

private class FriendRowAdapter extends ArrayAdapter<Friend>  { 

  public FriendRowAdapter(Context applicationContext, int friendlistRow,
    ArrayList<Friend> friends) {
   super(applicationContext, friendlistRow, friends);
  }

  @Override
  public View getView(int position,View convertView,ViewGroup parent) {
   Friend friend = getItem(position);
   FriendRowItem row = (FriendRowItem) convertView;
   if ( row == null ) {
    row = new FriendRowItem(ShowFriendsList.this.getApplicationContext());
   }
   row.setPropeties( friend );
   return row;
  }
 }
  • the problem is when I change the status of a friend from OFFLINE to ONLINE, then call notifyDataSetChanged(), nothing happens : the status icon of that friend doesn’t change.
    I tried debugging, and saw the code: notifyDataSetChanged() get called, but the custom getView() is not fired !

Can you please tell me, that is normal in Android, or did I do something wrong ? (I am using Android 1.5).

Thank you in advance,
Son

  • 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-18T22:45:51+00:00Added an answer on May 18, 2026 at 10:45 pm

    I am sorry,
    I have just found out: because I called the the method notifyDatasetChanged() in another thread (In fact, I am using Smack API to develop a chat client – and the method notifyDatasetChanged() is get called in a listener of smack, which in turn is run in another thread ).
    The correct solution: notifyDatasetChanged should be called like this:

        lvFriendList.post(new Runnable() {
    
            @Override
            public void run() {
                adapter.notifyDataSetChanged();         
            }
        });
    

    I hope this will spare somebody time, if they meet the same problem :).

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

Sidebar

Related Questions

I have searched/Googled around but I'm struggling with the following problem. I am building
I have searched a lot to find a solution for my problem, but I
I have searched the site for this simple problem but cant find an answer.
I have searched for the problem I am having, but have seen different variations
I have searched the web for this but so far got nowhere. I have
I have a problem while comparing the values in two vectors. Following is the
I have searched for similar issues but I found nothing... I have a problem
html load coming from NSString. I have the following problem: I get html code
I have following problem: when my session expires and user clicks on Ajax.Actionlink, Logon
I have following problem: I have built a tabbar application with 4 tabs. I

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.