开发者

Showing multiple activities on one screen?

开发者 https://www.devze.com 2023-01-18 02:14 出处:网络
I have an interesting problem and I was looking for a solution; Hoping that someone here can help me out.

I have an interesting problem and I was looking for a solution; Hoping that someone here can help me out.

(I did read through related questions on this topic but they have solutions which are not relevant to my situation).

Details are:

I have two activities. One is a simple list view to list available audio tracks. Another is a complex audio toolbar with controls to play/pause, ffd, and rewing the currently playing audio.

The audio toolbar uses a wrapper class that wraps the Android MediaPlayer object and this wrapper class is a singleton object. Which means that I eventually wish to use the audio toolbar anywhere in my app and control the singleton instance of my MediaPlayer wrapper.

For this reason, I cannot have the audio toolbar and the audio listview in the same activity since I want the toolbar to be a seperate entity altogether that pops up whenever the user wants to control the music, without having to see the listview.

Now, since the user would pop up the toolbar from anywhere in the app, I would love to know of a way to combine the current activity and the toolbar activity into one screen.

I do know that one option available to me is dialogs. I was looking 开发者_StackOverflowfor a more elegant solution where I could have the audio toolbar pop up at the bottom of the screen the user is on, without exiting the activity he is currently doing.

Anyone know of a way to do this? I didn't come across anything for this in the docs but if someone does know, even pointing me to the correct docs would be extremely useful :)

Thanks!


Another is a complex audio toolbar with controls to play/pause, ffd, and rewing the currently playing audio.

A toolbar should not be an activity. It should be a widget.

For this reason, I cannot have the audio toolbar and the audio listview in the same activity

Sure you can, by making it a widget.

Now, since the user would pop up the toolbar from anywhere in the app, I would love to know of a way to combine the current activity and the toolbar activity into one screen.

Step #1: Convert the "toolbar activity" into a widget

Step #2: Put the widget into the layout for your activity

I was looking for a more elegant solution where I could have the audio toolbar pop up at the bottom of the screen the user is on, without exiting the activity he is currently doing.

Step #1: Convert the "toolbar activity" into a widget.

Step #2: Put the widget into the layout for your activity, specifically in a RelativeLayout, with the toolbar anchored to the bottom of the RelativeLayout, initially set with visibility of GONE.

Step #3: Use a TranslateAnimation to display and hide the widget as needed, based on whatever trigger you were going to use.

See here for a sample application demonstrating this technique.


You want to implement an ActivityGroup. To embed the Activities, you would use the LocalActivityManager to start each activity, and grab the Activity's view and embed it into the layout/container that the ActivityGroup displays.

0

精彩评论

暂无评论...
验证码 换一张
取 消