Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/217.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
整个应用程序的通用页脚[Android]_Android_Footer - Fatal编程技术网

整个应用程序的通用页脚[Android]

整个应用程序的通用页脚[Android],android,footer,Android,Footer,好的,我想知道这是否可以做到 我所需要的只是一个普通的类似页脚的条,其中包含将要显示的广告。我想知道是否有什么方法可以让我的应用程序的这一部分成为一个普通部分 我知道include标记,但所做的只是在引用它的任何地方添加一个特定的布局。每次我从一个活动转到另一个活动时,它都会提示重新加载广告。这是非常烦人的,因为每次我移动到一个新的活动时都会发送一个新的广告请求 我正在使用admob显示广告。 希望我已经把问题说清楚了。以编程方式创建视图,然后将其存储在一个可以在整个应用程序中访问的文件中,这样

好的,我想知道这是否可以做到

我所需要的只是一个普通的类似页脚的条,其中包含将要显示的广告。我想知道是否有什么方法可以让我的应用程序的这一部分成为一个普通部分

我知道include标记,但所做的只是在引用它的任何地方添加一个特定的布局。每次我从一个活动转到另一个活动时,它都会提示重新加载广告。这是非常烦人的,因为每次我移动到一个新的活动时都会发送一个新的广告请求

我正在使用admob显示广告。
希望我已经把问题说清楚了。

以编程方式创建视图,然后将其存储在一个可以在整个应用程序中访问的文件中,这样可以避免每次都创建一个新视图

单例类示例:

  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();
View myview = footerStore.getFooter(thefooter);
您可以从以下所有活动中检索页脚:

MySingleFooter footerStore = MySingleFooter.getInstance();
footerStore.setFooter(thefooter);
MySingleFooter footerStore = MySingleFooter.getInstance();
View myview = footerStore.getFooter(thefooter);

然后按程序将其添加到当前活动中。

我想你是指包含标记yea yea,我实际上在那里键入了“”。那没有出现在那里!您可以编辑、突出显示它并按下
{}
按钮。它会加上两个倒引号(`)(这是他们的名字吗?),这样代码就格式化了。不知道为什么我以前没有想到这样的解决方案。非常感谢,我会测试它,并在我完成后将你的解决方案标记为正确答案。我没能在你的想法上取得进展。请