Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 在扫描图像时启动新活动_Android_Xml_Android Intent_Swipe Gesture - Fatal编程技术网

Android 在扫描图像时启动新活动

Android 在扫描图像时启动新活动,android,xml,android-intent,swipe-gesture,Android,Xml,Android Intent,Swipe Gesture,我有一个图像视图布局。在版面左侧滑动,我想调用一个新活动 Intent right_intent = new Intent(); right_intent.setClass(this, mainScreenClass.class); right_intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(right_intent); 我能够做到这一点,但新活动的召唤需要长时间的停顿。似乎在几分之一秒内什么都没有发生。 我可以做任

我有一个图像视图布局。在版面左侧滑动,我想调用一个新活动

Intent right_intent = new Intent();
right_intent.setClass(this, mainScreenClass.class);
right_intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(right_intent);
我能够做到这一点,但新活动的召唤需要长时间的停顿。似乎在几分之一秒内什么都没有发生。
我可以做任何事情,以便在没有任何时间的情况下滑动图像调用新活动。

为什么要使用Intent.FLAG\u activity\u CLEAR\u TOP?这将清除活动的堆栈

如果您使用的是gallery view类型的控件,则如果您从服务器下载图像并在该图像视图中显示,则可能会发生延迟,因此当您从服务器中滑动图像时,下一个图像将开始在下一个图像视图中加载。如果是这种情况,您可以尝试使用片段,这样gallery view和您调用的另一个新活动可以作为单独的片段创建,并且可以附加到单个FragmentActivity


这样,当在单个片段中滑动图像时,您可以将其替换为另一个片段您的新活动内容或使用indicator.onPageSelectedarg0保持另一个片段已选定您的新活动内容,与调用新活动内容相比,它将减少一定的延迟

您考虑过使用片段吗?这是实现这一目标的更好方法