How to implement a multi-window layout (for example, the default browser) (editor with several open files)

I am writing an editor (varieties) that I want to have in order to open several windows at the same time, and I want to be able to move between windows, as it can be done in the default browser application (Internet). See image: http: //i.imgur .com / LM6Nz.png for clarification.

My question is how to implement these windows; I want each window to be its own (Editor), I have to use Fragments (I mainly design for API 10, and Fragments come in API 11, but I read that this should be good). Or am I just hacking into several different views in a ViewGroup?

If I use fragments, place them in a ViewGroup?

+6
source share
3 answers

Fragments were intended for scenarios similar to that which you faced. Think about it, you need to show them all in the same action so that the action is not a suitable option. At the same time, you will want all of them to work independently and independently manage their own life cycle. You can support snippets since the API is no. 4 using the compatibility library. (Http://developer.android.com/tools/extras/support-library.html)

Ultimately, you can group them as you wish. This is one of the other strengths of the fragments. From the most basic container (FrameLayout) to the richest galleries such as ViewPager.

+6
source

I developed a similar application with four tabs (and you can add another if necessary). One for web browsing, one for facebook app and two others. I started them as one action and put all the views in one xml file (under different tabs). Worked very well for me.

Do you have any problems or just need a better way to do this?

+4
source

What you provided as a sample looks like a gallery - you can put a custom view there (override getView and inflate what you want).

If you want unlicensed windows, you need to use structures such as a gallery (dynamically load all the necessary information). Create your own layout, and in getView you can fill it as you like. And, for example, onItemClick you can go to another action, etc., to open it in full screen.

If you only need a preview, as in the example presented, you can create a simple gallery with preview images, if you want to perform some actions (possibly text images, etc.), you can do this as described above.

+3
source

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


All Articles