1

i've a simple chat application with ViewPager for Active Chats, now, i use

    @Override
    public int getItemPosition(Object object)
    {
        return POSITION_NONE;
    }

but this causes the all fragments to be recreated, and if there is too many messages it will lag, and also it closes keyboard whenever a message is received, so i attempted to override instantiateItem, but i couldn't get to anywhere, since i didn't know what to do with it, i wanted to update all listviews/fragments, not just the active one.

i also tried to use the onCreateView of fragments, get the listview, add an adapter to it, and add that adapter to a Array list, and whenever each messages comes, all adapters in this array list are updated, but this didn't work as expected, i had to move away from ViewPager then back to it again (Since the ViewPager is inside a tabHost) for messages to be displayed.

any help is appreciated, thanks.

1 Answers1

1

Please use setTag() method in getItemPostion() for the views to update them rather then returning POSITION_NONE. The reason of using setTag() and the way how to do that is well explained in this post ViewPager PagerAdapter not updating the View

Community
  • 1
  • 1
Marcin S.
  • 11,161
  • 6
  • 50
  • 63
  • i really don't know how to use this, can u give me some points? i'm new to android development, can u give me an instantiateItem example using this setTag() method?, thank you. – Zakri Vorschted Oct 02 '12 at 20:49