如何显示片段执行不同的活动? [英] How to show different Activities in Fragment implementation?

查看:119
本文介绍了如何显示片段执行不同的活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是采用了android片段我的第一次。我下面本教程以实施片段

It is my first time using android fragment. I am following this tutorial to implement a fragment.

一切都很好,这个教程中,我成功地得到的结果如下图所示:

Everything is fine with this tutorial, I successfully get the result like below:

在本教程中,在 DetailsFragment 只是显示了的TextView 包含当前选定项的文本。这是正确的部分显示只是一些文本。

In the tutorial, the DetailsFragment simply shows a TextView containing the text of the currently selected item. That's the right part shows just some texts.

我的问题是如何显示不同的活动在右侧,而不是文本的意见。

My question is how to show different activities on the right side instead of text views.

我的意思,如下图所示,例如面积 1 中的形象是一个活动。如何显示不同的活动时在左手侧的列表项选择了?

What I mean is illustrated in the following image, for example, the area of "1" in the image is an activity. How to show different activities when a list item on the left hand side has selected?

推荐答案

您不显示一个活动,你展示一个片段。实施片段类,而不是Activity类。然后你建立你的视图,就像你在一个活动将。请记住,情况下,当您需要访问一个活动的片段类有方便getActivity()方法。

You do not show an activity, you show a fragment. Implement the Fragment class instead of the Activity class. Then you build your View just as you would in an Activity. Remember that for instances when you need access to an activity the Fragment class has the convenient getActivity() method.

这篇关于如何显示片段执行不同的活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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