如何将片段镜像到Android中的演示文稿?

时间:2014-12-08 14:14:23

标签: android commonsware-cwac

对于那些熟悉这个主题的人来说,我的头衔可能是一个笑话,但我更愿意让你学习。

所以我的目标是在连接设备时在外部显示器中显示一个特定片段。显然,我从commonsware找到了很好的projet cwac-presentation:https://github.com/commonsguy/cwac-presentation

我设法运行 SimpleMirrorActivity WebMirrorActivity 的演示,分别显示 EditText 和同一版面上的网页。

然后,我查看了类 MirrorPresentationActivity 如何工作并设法运行它。它在外部显示器中显示一个网页。

但我的目标是显示一个特定的片段,我不认为有一个例子。我读了很多时间 MirrorPresentationFragment 的描述,但仍然不了解如何运行它。

是否可以获得一个或多个解释来做到这一点?

谢谢,这对我有很大帮助。

1 个答案:

答案 0 :(得分:1)

步骤1:将“一个特定片段”转换为MirroringFragment的子类。引用the documentation

  

MirroringFragment的工作方式与常规Fragment非常相似。但是,不是覆盖onCreateView(),而是覆盖onCreateMirroredContent()。 onCreateMirroredContent()采用与onCreateView()相同的参数,您的工作是相同的:创建片段显示的内容。区别在于您返回的视图将包装在MirroringFrameLayout中。

使用MirroringWebViewFragment作为示例的示例。或者,如果您的“一个特定片段”恰好是MirroringWebViewFragment,请直接使用WebViewFragment

步骤2:创建并使用MirrorPresentationFragment。引用the documentation

  

MirrorPresentationFragment是一个PresentationFragment,用于镜像MirroringFragment的内容。要使用它,请使用newInstance()工厂方法创建实例,将Context和所需的Display作为参数。然后,在MirroringFragment上调用setMirror(),提供MirrorPresentationFragment。从那里,你可以像任何其他PresentationFragment一样show()和dismiss()MirrorPresentationFragment。通过在主屏幕上显示MirroringFragment,并在外部显示器上显示MirrorPresentationFragment,无论用户在屏幕上操作的是什么,都会呈现给外部显示器,非常适合演示设置(例如,会议)。

有关如何一般使用PresentationFragmentMirrorPresentationFragment是子类)的说明,请参阅the documentationMirrorPresentationActivity演示了使用MirrorPresentationFragment

步骤3:啤酒。