为整个Android应用程序添加页脚

为整个Android应用程序添加页脚,android,footer,Android,Footer,在我的应用程序中,每个活动都有一个页脚。基本上,我在页脚中有一个ImageView,它从Web服务中获取图像并添加图像,并在一段时间间隔后更改图像,如滑动添加。我正在做的是在每个活动中添加页脚,并在每个活动中调用web服务将图像加载到ImageView,这对我的应用程序来说将是一个非常繁重的处理过程,因为我的应用程序中有许多Java类活动,所以我的问题是。。。 在安卓系统中,我可以为整个应用程序添加页脚吗?比如,如果我在底部的第一个活动中添加一个页脚,现在如果我移动到第二个活动、第三个活动等等…

在我的应用程序中,每个活动都有一个页脚。基本上,我在页脚中有一个ImageView,它从Web服务中获取图像并添加图像,并在一段时间间隔后更改图像,如滑动添加。我正在做的是在每个活动中添加页脚,并在每个活动中调用web服务将图像加载到ImageView,这对我的应用程序来说将是一个非常繁重的处理过程,因为我的应用程序中有许多Java类活动,所以我的问题是。。。 在安卓系统中,我可以为整个应用程序添加页脚吗?比如,如果我在底部的第一个活动中添加一个页脚,现在如果我移动到第二个活动、第三个活动等等……页脚仍然会在那里,这是我在第一个活动中添加的。使用与iPhone中相同的导航控制器


提前感谢

制作一个页脚xml文件,您希望在应用程序的所有屏幕上显示该文件,然后执行以下步骤:

创建一个Footer.java活动

public class Footer extends Activity {
        public void onCreate(Bundle savedInstanceState) {
             super.onCreate(savedInstanceState);
             setContentView(R.layout.footer);
        }
 }
然后在另一个类上扩展该类以供使用,如下所示:

public class Test extends Footer 
{
        @Override
        public void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
            ViewGroup vg = (ViewGroup) findViewById(R.id.lldata);
            ViewGroup.inflate(Home.this, R.layout.test, vg);
        }
}

制作一个要在应用程序的所有屏幕上显示的页脚xml文件,然后执行以下步骤:

创建一个Footer.java活动

public class Footer extends Activity {
        public void onCreate(Bundle savedInstanceState) {
             super.onCreate(savedInstanceState);
             setContentView(R.layout.footer);
        }
 }
然后在另一个类上扩展该类以供使用,如下所示:

public class Test extends Footer 
{
        @Override
        public void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
            ViewGroup vg = (ViewGroup) findViewById(R.id.lldata);
            ViewGroup.inflate(Home.this, R.layout.test, vg);
        }
}

以编程方式创建视图,然后将其存储在可在整个应用程序中访问的单例对象中,这将避免每次创建新视图

单例类示例:

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.setFooterthefooter

您可以从以下所有活动中检索页脚:

MySingleFooter footerStore=MySingleFooter.getInstance; 查看myview=footerStore.getFooterthefooter


然后以编程方式将其添加到当前活动。

以编程方式创建视图,然后将其存储在可在整个应用程序中访问的单例对象中,这将避免每次都必须创建新视图

单例类示例:

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.setFooterthefooter

您可以从以下所有活动中检索页脚:

MySingleFooter footerStore=MySingleFooter.getInstance; 查看myview=footerStore.getFooterthefooter

然后按编程方式将其添加到当前活动中