机器人:使用的ActivityGroup嵌入活动 [英] android: using ActivityGroup to embed activities

查看:112
本文介绍了机器人:使用的ActivityGroup嵌入活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

和即时消息在建立一个应用程序的概念化/设计阶段,我已经打了一个有点障碍的。实际上我一直在寻找一种方式来嵌入一个活动到另一个类似的用户界面如何TabHost / TabActivity。将有在其中将包括其他活性屏幕的顶部的窗口,并在下面这将是按钮和控制是独立于上述活动的,并应始终可见。用户将能够从一个活动导航到另一个窗口,而不会造成在下面的控制的任何变化。

Im in the conceptualizing/design phase of building an app and i've hit a bit of a snag. Essentially i was looking for a way to embed one activity into the UI of another similar to how a TabHost/TabActivity. There would be a window at the top of the screen which would contain the other activity, and below that would be buttons and controls that are independent of the above activity and should always be visible. The user would be able to navigate from one activity to another in the window without causing any change to the below controls.

而寻找到的问题我跑过的ActivityGroup,看起来像这将是有益的,但​​如何将我实现它?任何有经验的ActivityGroup或有其他想法?

While looking into the issue i ran across ActivityGroup, which looked like it would be useful, but how would i implement it? Anyone have experience with ActivityGroup or have another idea?

推荐答案

是的,你会实施的ActivityGroup,这将是您的其他活动的容器。当用户点击一个按钮,你会得到一个参考LocalActivityManager,并用它来启动,并嵌入内心活动。事情是这样的:

Yes, you'd implement an ActivityGroup, which will be the container of your other Activities. When the user clicks one of the buttons, you'd get a reference to the LocalActivityManager, and use it to start, and embed the inner activity. Something like this:

LocalActivityManager mgr = getLocalActivityManager();

Intent i = new Intent(this, SomeActivity.class);

Window w = mgr.startActivity("unique_per_activity_string", i);
View wd = w != null ? w.getDecorView() : null;

if(wd != null) {
    mSomeContainer.addView(wd);
}

请注意,使用这种方法可以是pretty的复杂,因为除非聚焦正好,pressing硬件按钮(像菜单按钮)将仅仅触发事件上的ActivityGroup代替内活动。你必须找到某种方式之后将其添加到容器视图,在该点的甚至会发生在内部的活动并传播到容器活动集中的内活性

Note, using this method can be pretty complicated, because unless the focus is just right, pressing the hardware buttons (like the menu button) will only only trigger events on the ActivityGroup instead of the inner Activity. You have to find some way to focus the inner activity after you add it to the container view, at which point the even will happen in the inner activity and propagate to the container activity.

这是可以做到的,我已经做到了...和它的作品。这只是一个比较复杂一点比我想应该是。

It can be done, I've done it... and it works. It's just a bit more complicated than I think it should be.

不管怎样,我通过看TabHost code,它可以找到<一拿到其中的大部分信息href="http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob_plain;f=core/java/android/widget/TabHost.java;hb=HEAD">here

Anyway, I got most of this information by looking at the TabHost code, which can be found here

这篇关于机器人:使用的ActivityGroup嵌入活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆