Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement multi-windowed layout (like the default browser) (Editor with several open files)

I am writing an editor (of sorts) which I want to be able to have multiple windows open at the same time, and I want to be able to navigate between windows as can be done in the default browser (Internet) application. See picture: http://i.imgur.com/LM6Nz.png for clarification.

My question is how to implement these windows; Do I want each window to be an own (Editor) Activity, should I use Fragments (I am mainly designing for API 10, and Fragments arrived in API 11, but I read somewhere this should be fine). Or do I simply hack together some different Views in a ViewGroup?

If I use Fragments, do I place them in a ViewGroup?

like image 662
Pål GD Avatar asked Jul 31 '12 11:07

Pål GD


2 Answers

I developed a similar app with four tabs (and more can be added if desired). One for a webview, one for a facebook app and two others. I started them as one single activity and put all the views in one single xml file (under different tabs). Worked pretty fine for me.

Are you encountering any problems or just want a better way to do this thing?

like image 30
Adnan Zahid Avatar answered Oct 26 '22 23:10

Adnan Zahid


Fragments were meant for scenarios similar to the one you are facing. Think about it, you need to show them all in the same activity so an Activity won't be a proper option. At the same time you'll want for all of them to work independently and to manage their own lifecycle internally. You can support fragments since API no. 4, by using the compatibility library. (http://developer.android.com/tools/extras/support-library.html)

Ultimately you can group them as you like/need. That's one of the other strengths of fragments. From the most basic container (FrameLayout) to the richest galleries such as ViewPager.

like image 155
Jose L Ugia Avatar answered Oct 26 '22 23:10

Jose L Ugia