Android的活动与意见 [英] Android Activities vs Views

查看:167
本文介绍了Android的活动与意见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对不起,我知道,这个话题已经被覆盖了一下。我读过相关的职位,我还是有点困惑。我工作的一个应用程序,而样机将有3个主屏幕,它最终将有几十个。每个屏幕将present要么dynmically改变现状或采取用户输入。为了可视化,需要进行布局类似于MS Word或一个典型的PC如何。它在顶部的状态栏和导航栏底部所共有的,中间的所有屏幕(略微调整了一段画面,就像不同的图标)是我所说的,需要有一个更新视图窗格适用的布局。

Sorry, I know that this topic has been covered a bit. I've read the related posts and am still a bit confused. I am working on an app that while the prototype will have 3 main screens, it will eventually have dozens. Each screen will present either dynmically changing status or take user input. To visualize, it is required to be laid out similar to how MS Word or a typical PC is. It has a status bar at the top and a navigation bar at the bottom that is common to all screens (slight tweaks for some screens, like different icons) in the middle is what I would call a view pane that needs to be updated with a applicable layout.

状态,导航栏,每个画面都在他们自己的布局的XML文件中定义。对于我在这第一次的赃物我只是用一个ViewFlipper和装载3的屏幕布局进去。但是这意味着,目前我有这不会是维护我继续补充屏幕中的一个主要活动。

The status, nav bar, and each screen are defined in their own layout xml file. For my first swag at it I just used a ViewFlipper and loaded the 3 screen layouts into it. However that means that currently I have one main Activity which will not be maintainable as I continue to add screens.

  1. 这感觉不错,我认为每个屏幕的布局应该有一个了解如何控制屏幕相关的活动类。我需要弄清楚如何动态加载到中心窗格。不过,我想我读在另一篇文章,使用多个活动可以是CPU和内存消耗。
  2. 现在我试图使屏幕的一个它自己的活动,并踢了开来的主要活动通过创建一个Intent,比调用startActivity。然而,导致新的屏幕活动驻留在主要活动上。有趣的是,那么pressing后退按钮驳回该活动并返回我的主。
  3. 到目前为止,我还没有想出如何设置具有不同的活动控制在中心窗格中会发生什么。
  4. 如果我继续向下多个活动路径,应我的主要活动是从的ActivityGroup继承?
  5. 使用视图类更适用于这种情况?

我知道这是一个漫长的职位。我倒是AP preciate任何意见。 谢谢! CB

I know this has been a long post. I'd appreciate any advice. Thanks! CB

推荐答案

正如你注意到,Android将隐式跟踪任务的堆栈开始的活动,和返回按钮结束最上面的一个,重新激活下一个下降。我会建议你考虑一下哪种事物的用户所期望的后退按钮做的,让这个活动是沿着这些线路的分离。

As you noticed, Android will implicitly track a stack of started activities in a task, and the 'back' button ends the top one, reactivating the next one down. I would advise you to think about which kinds of things the user might expect the back button to do, and make it so that activities are separated along those lines.

我还没有发挥的ActivityGroup ,所以我不能劝你那里。如果你去完全独立的活动,你可以让他们都使用相同的壳的内容与普通导航/状态栏查看。有一个超类或实用类柄填充和管理从那里。然后使用AA LayoutInflater (你可以叫 getLayoutInflater())填写您的活动特定视图的中央。

I haven't played with ActivityGroup so I can't advise you there. If you go with completely separate activities, you can have them all use the same "shell" content view with the common nav/status bar. Have a superclass or utility class handle populating and managing that from there. Then use a a LayoutInflater (you can call getLayoutInflater()) to fill in the middle with your Activity-specific view.

如果你想活动之一,有多个屏幕,你可能仍然结束了在中心插槽ViewFlipper。同样,你想无论你希望用户能够回到有一个活动的过渡;这也意味着你可能不希望有活动的情况下发生变化,其中屏幕是密切相关的同一逻辑的事情感 - 完成全部或部分。 (您可以覆盖后退按钮的行为,但除非你有一个很好的理由,最好只安排应用程序,使Android的基本设置可帮助您的应用程序的用户界面,而不是相互矛盾的工作。)

If you want one of the activities to have multiple screens, you might still end up with a ViewFlipper in the center slot. Again, you want to have an Activity transition wherever you want the user to be able to go "back"; that also means you may NOT want to have a change of activities in cases where screens are closely related or part of the same logical thing-being-done. (You can override the back button's behavior, but unless you have a good reason to, it's best to just arrange the app so that Android's basic setup helps your app's UI rather than working at cross purposes.)

这篇关于Android的活动与意见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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