Android的:如何在点菜iPhone相同的活动浏览网页 [英] Android : how to browse page in the same activity à la iPhone

查看:89
本文介绍了Android的:如何在点菜iPhone相同的活动浏览网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,在Android中的活动重新presents屏幕的生命周期。 随着startActivity(意向),应用程序那张新的活动。 如何实现变页像同一个活动点菜iPhone?在选项触摸屏。

Basically, in Android an Activity represents a screen lifecycle. With startActivity(intent) , the app goes on a new Activity. How to achieve "change page" in the same activity à la iPhone like ? with touch screen in option.

这背后的问题的原因是 我发现了一个Android应用程序Diet2Go。当你选择一个饮食。 在选项卡我的饮食,您可以通过网页浏览你的饮食页面。 我知道这是因为,当你在$后退按钮p $ PSS,您返回到您的主屏幕是在相同的活动。

The reason behind this question is I discovered an Android app Diet2Go. When you pick a diet. In the tab "My diet" , you can browse your diet page by page. I know it's in the same activity because when you press on Back button, you return back to your home screen.

推荐答案

更​​改页面在同一个活动是没有任何幻想,只需要调用的setContentView()再次需要的时候,例如。或者,如果这是一个矫枉过正,只需要添加/删除/隐藏/取消隐藏意见您的布局在运行时。检查View类的这个方法。你甚至可以动画在屏幕上的东西,所以它看起来像一个页面翻转,或常规活动的变化,等等。

Changing the page in the same Activity is nothing fancy, just call "setContentView()" again when needed, for example. Or if that's an overkill, just add/remove/hide/unhide views on your layout during runtime. Check the methods of the View class for this. You may even animate stuff on the screen, so it looks like a page-flip, or a regular activity-change, whatever.

另外,不要让基于后退按钮的行为做任何假设。您可以覆盖按钮的行为,所以它任何你喜欢的,不是neccesarily采取用户返回到previous活动。

Also, don't make any assumptions based on the behavior of the back button. You can override that button's behaviour, so it does anything you like, not neccesarily taking the user back to the previous Activity.

这篇关于Android的:如何在点菜iPhone相同的活动浏览网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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