Note that there are some explanatory texts on larger screens.

plurals
  1. POgetView() (for a Custom ListView ) doesn't get called on notifyDatasetChanged()
    primarykey
    data
    text
    <p>I have the following problem, and searched for a while but haven't got any solution from the net: </p> <p>I have a custom list view, each item has the following layout (I just post the essential):</p> <pre><code>&lt;LinearLayout&gt; &lt;ImageView android:id="@+id/friendlist_iv_avatar" /&gt; &lt;TextView andorid:id="@+id/friendlist_tv_nick_name" /&gt; &lt;ImageView android:id="@+id/friendlist_iv_status_icon" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>And I have a class FriendRowItem, which is inflated from the above layout:</p> <pre><code>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); } } </code></pre> <p>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: <code>ArrayList&lt;Friend&gt; friends</code>:</p> <pre><code>private class FriendRowAdapter extends ArrayAdapter&lt;Friend&gt; { public FriendRowAdapter(Context applicationContext, int friendlistRow, ArrayList&lt;Friend&gt; 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; } } </code></pre> <ul> <li>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.<br> I tried debugging, and saw the code: notifyDataSetChanged() get called, but the custom getView() is not fired ! </li> </ul> <p>Can you please tell me, that is normal in Android, or did I do something wrong ? (I am using Android 1.5).</p> <p>Thank you in advance,<br> Son</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload