Android: on a switch between views / actions / snippets

I am using a chat application. The user can open several chats at the same time, and I want to allow him to switch between these chats with scrolling left or right. Like the gtalk app, for example. I am not sure what the best way to implement this is:

  • Should I use one chat activity? If so, how to choose the right instance of activity to go to the next chat?
  • Should I use only one instance of Activity and several views and switch between them, as in this example ?
  • Or should I use Fragments and switch between them? Does the FragmentManager provide a way to select the correct fragment instance to switch between?

What do you think is the best solution and why? Any suggestions? Thanks for your help!

+6
source share
1 answer

I would advise taking a look at the following Android Dev blog post about using ViewPager in the Android compatibility pack to implement the swipe functionality you are looking for:

http://android-developers.blogspot.com/2011/08/horizontal-view-swiping-with-viewpager.html

The recommended approach is most likely to use a snippet for chat history and text input, as this will give you maximum flexibility on all devices.

+12
source

Source: https://habr.com/ru/post/896300/


All Articles