固定页眉和页脚的Andr​​oid应用 [英] Fixed header and footer in android app

查看:140
本文介绍了固定页眉和页脚的Andr​​oid应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要使用固定的页眉和页脚在我的Andr​​oid应用程序,但每次新活动开始时,页面刷新,并都页眉和页脚重装。结果
我怎样才能让他们通过固定了应用程序生命周期,让他们从来没有重装,虽然我可以隐藏,删除和添加项目呢?

I want to use fixed header and footer in my android app, but every time a new activity starts, the page refreshes and both the header and footer reload.
How can I make them fixed through out the application life cycle so that they never reload, although I can hide, remove and add items to them?

我已经使用了包括标签,这不是我想要的。

I've used the include tag and it's not what I want

推荐答案

您可以使用一个活性的页眉,页脚和内容片段。相反,开始新的活动,你会改变的内容片段。

You may use one Activity with header, footer and the content Fragment. Instead of starting new Activity, you'll change the content Fragment.

但是,这不是既不由Android也不是由用户的预期。你也需要某种形式的后退按钮处理,状态保存/恢复等。你确定你想要做你所描述的?

But. This is not expected neither by Android nor by user. Also you need some kind of Back button handling, state saving/restoring and so on. Are you sure that you want to do what you described?

如果是这样,这里有一些有用的链接:

If so, here are some useful links:

  • Fragments;
  • Building a Dynamic UI with Fragments;
  • Add a Fragment to an Activity at Runtime;
  • FragmentTransaction - for custom transaction animation see setTransition() and setCustomAnimations() methods.

另外,如果你想在Android 3.0之前(API级别11),你需要的支持库
对于自定义动画中天

Also if you want to use fragments on Android prior 3.0 (API level 11), you'll need the Support Library For custom transit animation

这篇关于固定页眉和页脚的Andr​​oid应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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