调用的主要活动的方法。从自定义视图类 [英] call a method in the main Activity. From a Custom View class

查看:89
本文介绍了调用的主要活动的方法。从自定义视图类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一种新的应用我开发了下面的方法。

i am using the following method in a new application i'm developing.

还有一个主要活动,其中实例化扩展RelativeLayout的不同类别,而我使用的setContentView到应用程序的不同模块之间进行切换。

there is a main activity, which instantiates different classes that extends RelativeLayout, and i'm using setContentView to switch between the different modules of the application.

我不知道这是否是一个很好的方法或necesarily我必须使用不同的活动向几个屏幕的应用富人。

i wonder if this is a good approach or necesarily i have to use different activities to the several screens the app haves.

推荐答案

我推荐使用不同的活动,那么你通过自动后退按钮让他们之间的导航。另外,将有微妙的东西,将无法正常工作,如果你这样做你所描述的方式 - 例如,机器人会自动保存,当您切换活动集中控制。它不会对你的内容的看法做到这一点;你必须保存/恢复关注自己。

I'd recommend using different activities, then you automatically get navigation between them via the back button. Plus, there will be subtle things that won't work right if you do it the way you're describing -- for example, Android automatically saves the focused control when you switch activities. It won't do this for your content views; you would have to save/restore focus yourself.

另外,如果它不为用户去来回你的应用程序的屏幕之间意义,那么你仍然可以实现与多个活动的应用程序,使用 android.app .TabHost 。这就是跟应用程序使用,例如。然后每个屏幕仅仅是一个子活动,整个应用程式真视为单个活性。如果你愿意,你可以使用 TabHost ,而不必实际标签。您可以隐藏的选项卡,并启用通过按钮或菜单项,而不是导航。

Alternatively, if it doesn't make sense for a user to go "back and forth" between the screens of your application, then you could still implement the application with multiple activities, using android.app.TabHost. This is what the Contact app uses, for example. Then each screen is just a sub-activity, and the whole app is really treated as a single activity. And if you want, you can use TabHost without actually having tabs. You can hide the tabs and enable navigation via buttons or menu items instead.

这篇关于调用的主要活动的方法。从自定义视图类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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