Hi All,
Currently i m working on IM, and I am facing problem during
implementations. I am implementing this messenger using XMPP client
and using smack API for implementing all features like contacts list,
online offline status, and chat also.
Prblem which I am facing:
**********************its my list view where i am showing contacts
list*************************
public class ContactsList extends ListActivity implements
OnClickListener{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ContactsManager manager = new ContactsManager(this);
setListAdapter(manager);
}
public class ContactsManager extends BaseAdapter{
private LayoutInflater mInflater;
private Bitmap mainListIcons[];
private static ContactsInfo contactsInfo;
public ContactsManager(Context context) {
mInflater = LayoutInflater.from(context);
mainListIcons= new Bitmap[3];
mainListIcons[0] = BitmapFactory.decodeResource
(context.getResources(), R.drawable.online);
mainListIcons[1] = BitmapFactory.decodeResource
(context.getResources(), R.drawable.offline);
}
@Override
public int getCount() {
return Global.contacts.size();// contacts is vector where i m
saving
my contacts
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup
parent) {
ViewHolder holder;
if (convertView == null)
{
convertView = mInflater.inflate
(R.layout.main_settings_lists_icon_text, null);
holder = new ViewHolder();
holder.mainListDisplayText = (TextView)
convertView.findViewById(R.id.main_settings_lists_text);
holder.mainListDisplayIcon = (ImageView)
convertView.findViewById(R.id.main_settings_lists_icon);
convertView.setTag(holder);
}else{
holder = (ViewHolder) convertView.getTag();
}
contactsInfo = (ContactsInfo)Global.contacts.elementAt
(position);
String username = contactsInfo.getUsername();
String status = contactsInfo.getUserstatus();
if(status.equalsIgnoreCase("unavailable"))
{
holder.mainListDisplayIcon.setImageBitmap(mainListIcons[1]);
}else{
holder.mainListDisplayIcon.setImageBitmap(mainListIcons[0]);
}
holder.mainListDisplayText.setText(username);
return convertView;
}
static class ViewHolder
{
TextView mainListDisplayText;
ImageView mainListDisplayIcon;
}
*********************************************************************
public class ContactsHandler implements RosterListener {
@Override
public void entriesAdded(Collection<String> c) {
for(String s:c)
{
Log.i("ADDED Contacts",s);
}
}
@Override
public void presenceChanged(Presence p) {
Log.i("PRESENCE",p.getFrom());
Log.i("IS Available",""+p.isAvailable());
Log.i("UserStatus",""+p.getStatus());
if(p.getFrom().contains("@") && p.isAvailable())
{
ChatManager chatmanager = Connection.getVopConnection
().getXMPPConnection().getChatManager();
Chat newChat =
chatmanager.createChat("gul...@imran-mehmood", new
ChatHandler());
}
}
}
At presenceChanged(Presence p) method i have received the status of
user that for online or offline i will add the object in
Global.contacts vector but i dont know how i will refresh the contacts
list view like in J2ME we have called repaint() method.but here i dont
know how i will invoke that user status has been changed and list view
update against newly updated user status. any one can help me
regarding this how i will refresh list view after adding my
contactslist in adapter thanks in advance
Regards,
Gulfam
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---