添加页脚为整个Android应用程序 [英] Add Footer for whole Android Application
问题描述
在我的应用程序为每个活动页脚
。基本上我在页脚中的ImageView
这得到 Web服务的图片(增加图片)
和一段时间间隔后改变图像(如滑动补充)。什么我做的是将在每一个活动,并调用Web服务页脚在每个活动加载图像到的ImageView
(这将是一个非常沉重的处理我的应用程序,因为我有许多 Java类(活动)
在我的应用程序),所以我的问题是...
是否有任何Android的方式,我可以为整个应用程序中添加脚注?就像如果我添加一个页脚第一项活动
底部,现在如果我移动到第二个活动,第三个活动
等上....页脚将仍然存在,我已经在第一个活动添加
。 (同样喜欢在iPhone 导航控制器
时)
In my application I have a footer for each activity
. Basically I have an ImageView
in footer which get Images (adds Images) from Web service
and change images after some time interval (like sliding adds). What I am doing is adding footer in each activity and call web service in every activity to load images into ImageView
(which is going to be a very heavy processing for my app because I have many Java classes(Activities)
in my app), so my question is...
Is there any way in android that I can add footer for whole application? like if I add a footer in first activity
at bottom, now if I move to second activity, third activity
and so on....the footer will still there which I've added in the first activity
. (same like in iPhone Navigation controller
is used )
在此先感谢
推荐答案
创建视图编程然后将其存储在其中可以在整个应用程序可以访问一个单独的对象,这将避免创建一个新的视图各一次。
Create your view programatically then store it in a singleton object which can be accessed throughout the application, this will avoid having to create a new View each time.
Singleton类例如:
Singleton class example:
public class MySingleFooter{
MySingleFooter mySingleFooter;
View myFooter;
private MySingleFooter(){}
public static MySingleFooter getInstance()
{
if (mySingleFooter == null)
{
mySingleFooter = new MySingleFooter();
}
return mySingleFooter;
}
void setFooter(View myFooter)
{
this.myFooter = myFooter;
}
View getFooter()
{
return myFooter;
}}
您可以从这样的所有活动设置页脚
MySingleFooter footerStore = MySingleFooter.getInstance();
footerStore.setFooter(thefooter);
MySingleFooter footerStore = MySingleFooter.getInstance();
footerStore.setFooter(thefooter);
您可以检索的所有活动像这样的注脚:
You can retrieve the footer from all activities like this:
MySingleFooter footerStore = MySingleFooter.getInstance();
查看MyView的= footerStore.getFooter(thefooter);
然后将其添加到编程当前活动。
Then add it to the current activity programatically.
这篇关于添加页脚为整个Android应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!