简体   繁体   English

片段活动

[英]Activity to Fragments

I have 3 android activities and one of them has a surfaceview used to preview the camera. 我有3个android活动,其中之一有一个Surfaceview用于预览相机。 When I swipe right on this activity, an intent is launched and a swipe animation occurs and the other activity is launched. 当我在此活动上向右滑动时,将启动一个意图,并发生滑动动画并启动另一个活动。 A similar thing happens when I swipe to the left. 当我向左滑动时,也会发生类似的情况。 However, do to the live preview of the camera in the central activity, this is quite laggy and slow, and the screen turns white first before the other activity is launched. 但是,请对中央活动中的摄像机进行实时预览,这相当缓慢且缓慢,并且在启动其他活动之前,屏幕首先变白。 To improve this process, I am considering converting the three activities into fragments and using the ViewPager concept to implement these sliding transitions. 为了改进此过程,我正在考虑将这三个活动转换为片段,并使用ViewPager概念来实现这些滑动过渡。 Is the process of converting the activities to fragments something trivial or is it something that requires a lot of effort which wouldn't be justifiable in this case? 将活动转换成碎片的过程是微不足道的还是需要大量的工作,在这种情况下是不合理的?

Its quite easy to do. 它很容易做到。 You just have to copy paste your activity view building code to the Fragment, everything stays the same. 您只需要复制粘贴活动视图构建代码到Fragment,一切就保持不变。 I would think the effort is just 2 hours to refactor it, its worth it. 我认为只需花费2个小时即可对其进行重构,这是值得的。 http://developer.android.com/training/basics/fragments/creating.html http://developer.android.com/training/basics/fragments/creating.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM