Android: Viewing Two Activities in One Screen
Asked Answered
E

3

6

I'm looking for the simplest way to have two activities displayed at once, so that one Activity always remains visible, and the other changes with user interaction.

In other words:

  • I currently have code for a program with several Activities.
  • The user can navigate between these activities.
  • I want to add a new Activity that will always be visible alongside what I already have.
  • When the user navigates from the current Activity to another one, this new "side Activity" will remain visible.

I've seen many different ideas for doing something similar, but haven't been able to adapt them to my needs.

Any help would be appreciated.

Endopeptidase answered 29/3, 2011 at 17:17 Comment(0)
C
6

None of what you want is possible with activities. The closest thing is using themes so that your "side activity" is partially visible behind other non-full-screen activities. However, getting this to work properly on a wide range of screen sizes will be difficult, and managing your task stack to pull this off does not strike me as being much fun.

You should be able to create something that resembles what you seek with the proper application of fragments, but you will wind up with one large activity and a bunch of fragments, as opposed to a bunch of activities.

At the activity level, Android is not designed for some persistent element that you seek.

California answered 29/3, 2011 at 17:25 Comment(0)
P
3

You can achieve something that is similar to what you want (in terms of what the user sees). But it wouldn't be actually two activities running.

Check Fragments Documentation. I think you want to use two fragments: one on the top of the screen and another one on the bottom.

Perjured answered 29/3, 2011 at 17:36 Comment(0)
G
3

Like others have said, you can't have multiple Activities on screen at once. However, you could refactor your separate activities into Views, then show a single Activity with one persistent View alongside a group of swappable Views (managed by tabs or ViewFlipper).

Geaghan answered 29/3, 2011 at 20:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.