Android Best Practice - Views / Actions

Just start developing Android. To start, I create an application that will function as a gallery + image viewer, with the added functionality of quickly and quickly moving images to subfolders, for easy sorting of a large number of images.

So far, I have two activities - a full-screen image and a full-screen thumbnail (for multi-segment purposes).

Now that I'm new to this, I was wondering if this double action was a wise decision. It would be better to simply switch between content views than activate a completely different activity when switching from image view to grid (and vice versa).

I'm looking, of course, for the obvious pros and cons - performance, simplicity and ease of use. But also, if there are more fundamental “patterns” / best practices for one or the other.

thanks

+6
source share
3 answers

I think your approach to dual activity is reasonable. Generally speaking, the Android Activity / View APIs are structured around one fixed view for each operation. Although you can manipulate the views in the layout of your activity, I would suggest that this be limited to hiding / showing / moving views, rather than replacing the layout.

What you should probably consider is the new snippets API . It can be almost like “activity within the framework of activity”. A snippet essentially allows you to wrap a user interface element (layout and behavior) in a reusable component. Thus, in your specific example, two different user interfaces can be fragments in a single action.

This has several advantages, such as the ability to reuse your user interfaces in other actions, and you can create funky transition animations.

+5
source

double activity should work, since you don’t have to worry about implementing the action of the back button.

+1
source

The events were made just for this purpose. If you prefer, you can have your entire application in one action using a custom layout mechanism (reload components, etc.) and what you want to do if you want a “portable” application (for example, you are developing an application with a common UI for various platforms, Andropid, Windows 7, iOS, etc.), but if you want to switch only to Android, the preferred way is to use the provided APIs rather than reinvent the wheel. It works great and will give users a sense of comfort in their experience (it will look and feel like other Android apps).

In the current project I'm working on (the game), there are already 10 different activities, and I plan more ...

+1
source

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


All Articles