- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我为 Admob 编写了代码。这是我的 layout.xml 文件代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:id="@+id/relativeLayoutHomeParent"
tools:context=".Home" xmlns:app="http://schemas.android.com/apk/lib/com.google.ads">
<RelativeLayout
android:id="@+id/relativeLayoutHomeTopBar"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
<TextView
android:id="@+id/textView1"
android:text="Home"
style="@style/screen_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView
android:id="@+id/imageViewHomeSettings"
android:layout_width="22dp"
android:layout_height="22dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="@drawable/set_settings"
android:layout_marginRight="10dp" />
</RelativeLayout>
<View
android:id="@+id/view1"
android:layout_width="match_parent"
android:layout_height="5dp"
android:layout_below="@+id/relativeLayoutHomeTopBar"
android:background="@drawable/shadow" />
<ListView
android:id="@+id/listViewHome"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#BDBDBD"
android:dividerHeight="1dp"
android:layout_below="@+id/view1" >
</ListView>
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
app:adSize="BANNER"
app:adUnitId="a1512f50d8c3692"
app:loadAdOnCreate="true"
app:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" >
</com.google.ads.AdView>
输出:
我的activity.java代码:
package com.walletapp;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.google.ads.AdRequest;
import com.google.ads.AdSize;
import com.google.ads.AdView;
public class Home extends Activity
{
ListView listview_home;
ImageView imageview_settings;
SQLiteDatabase database;
String database_name = "WalletAppDatabase";
private AdView adView;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
imageview_settings = (ImageView) findViewById(R.id.imageViewHomeSettings);
imageview_settings.setClickable(true);
imageview_settings.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v)
{
startActivity(new Intent(Home.this, Settings.class));
}
});
String[] home_items = new String[] {"All", "Categories", "Tags", "Favourites"};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.single_row_home, R.id.textViewSingleRowHome, home_items);
listview_home = (ListView) findViewById(R.id.listViewHome);
listview_home.setAdapter(adapter);
listview_home.setOnItemClickListener(new OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3)
{
String selected = ((TextView) arg1.findViewById(R.id.textViewSingleRowHome)).getText().toString();
switch(arg2)
{
case 0:
Toast.makeText(getBaseContext(), "Yet to be code for "+selected, Toast.LENGTH_SHORT).show();
break;
case 1:
Toast.makeText(getBaseContext(), "Yet to be code for "+selected, Toast.LENGTH_SHORT).show();
break;
case 2:
Toast.makeText(getBaseContext(), "Yet to be code for "+selected, Toast.LENGTH_SHORT).show();
break;
case 3:
Toast.makeText(getBaseContext(), "Yet to be code for "+selected, Toast.LENGTH_SHORT).show();
break;
}
}
}
);
adView = new AdView(this, AdSize.BANNER, "a1512f50d8c3692");
RelativeLayout layout = (RelativeLayout)findViewById(R.id.relativeLayoutHomeParent);
layout.addView(adView);
adView.loadAd(new AdRequest());
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if(keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0)
{
showQuitDialog();
return true;
}
return super.onKeyDown(keyCode, event);
}
private void showQuitDialog()
{
AlertDialog.Builder adb = new Builder(this);
adb.setTitle("Warning !!!");
adb.setMessage("Are you sure you want to quit ?");
adb.setIcon(R.drawable.ic_launcher);
adb.setPositiveButton("Yes",new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface arg0, int arg1)
{
if(database.isOpen())
database.close();
finish();
}
}
);
adb.setNegativeButton("No",new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface arg0, int arg1)
{
arg0.dismiss();
}
}
);
AlertDialog ad = adb.create();
ad.show();
}
@Override
public void onDestroy()
{
if (adView != null)
{
adView.destroy();
}
super.onDestroy();
}
}
我想要位于屏幕底部的顶部栏(是的,黑色栏)。我也为它写过,但它显示的输出如上图所示。
我也不明白哪个是 admob 横幅,顶部的还是底部的??谁能解释一下这两个酒吧的区别。其实我是新来的。这是我第一次为 admob 编写代码。请帮助我学习这一点。
最佳答案
两者都是 admob banner
。如果您希望在底部显示广告,请从您的 Activity
中删除以下代码,因为您已经在 xml 中为底部添加了代码。
adView = new AdView(this, AdSize.BANNER, "a1512f50d8c3692");
RelativeLayout layout = (RelativeLayout)findViewById(R.id.relativeLayoutHomeParent);
layout.addView(adView);
adView.loadAd(new AdRequest());
关于android - Admob 横幅不在屏幕底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15151893/
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 1年前关闭。 Improve thi
当我在 Admob 页面中创建插页式广告单元时,它要求输入 Interstitial timeout : Determine how long to display the interstitial
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 2年前关闭。 Improve thi
我的应用使用奖励视频广告,但在我看来,有时广告太长了。如何设置广告的时长限制? 最佳答案 这不是 AdMob 提供的功能。不过,感觉太长的广告通常会获得较少的点击次数,因此随着系统的调整,展示次数会越
我正在使用 admob 插页式广告,它通过 onCreate 加载 所以我可以使用它一次,但不能使用两次。我必须重新加载它然后使用它... 我想在显示后立即重新加载它,但似乎没有这样的回调监听器...
我有 admob 帐户,并且广告单元已成功放入我的应用程序中。 现在我想在我的应用程序中打印 admob 报告,就像用户 ABC 在这个应用程序中点击了“_”次赚取和应用程序的 RPM 我该怎么做,有
这可能是题外话,但请这对我们所有人都非常有帮助,他们从未知来源获得虚假点击,只是为了暂停我们的 admob 帐户。 最佳答案 对于 iOS 您应该使用 here 所述的委托(delegate)方法计算
Admob 几天前迁移到了较新的版本。他们成功转移了我的应用程序,但似乎我必须从 0,00 美元重新开始。我的旧 Admob 大约有 15 美元。我怎样才能把它转移到新的,否则它会丢失吗?支付限额为
我认为有人试图让我在 AdMob 中被禁止 - 在来自“未知”国家/地区的地理统计点击中,点击率达到 80%-90%(其他国家/地区 < 3%)。 如果用户来自“未知”国家/地区,是否有办法阻止展示广
我在展示来自 admob 的广告时在布局上遇到了一些问题。 应用刚启动时没有广告,一切正常。布局占据整个屏幕。然后当应用程序可以加载广告时(在顶部),整个布局将向下移动以显示广告。 如果有广告时整个布
是否可以在 Android 上以多种语言显示 GDPR 同意对话框? 我只能用一种语言发布一条消息。 在ump sdk中没有看到拟合方法。 我的意思是必须有办法做到这一点,如果没有,那么这个 sdk
我在 iOS 游戏中使用 AdMob,我最近更新了它以在我的 Info.plist 文件中包含 AdMob SKAdNetworkIdentifier(因为我的 AdMob 帐户中有警告要求这样做)。
这是我的代码: gAdView=[[GADBannerView alloc] initWithFrame:CGRectMake(0,self.view.bounds.size.height-GAD_S
Google 对使用 是否有限制或警告?奖励广告 限时? 因此,在我的应用程序中,如果我让我的用户按他/她想要的次数观看激励广告,将 谷歌 将其视为 无效流量这会导致帐户停用? 最佳答案 不,激励广告
我在 Google Play 上发布了一个游戏,我在上面放了 admob 广告。 由于无效的点击事件,我的 admob 帐户被禁用。 现在我创建了另一个帐户,将我的游戏链接到它。 我显示广告的代码是正
关于 AdSense 报告 API - GET/accounts/accountId/reports 它是仅检索 AdMob 数据(作为广告网络)还是也可以包括来自其他中介广告网络的数据? 最佳答案
我已经知道这个问题的答案,但我之所以这么问,是因为我花了几个小时才找到它,并且想让其他人轻松获得它。 自 2020 年 12 月 8 日起,Apple 已强制要求开发人员发布正在收集的数据以及这些数据
使用 AdWhirl 我得到了这些异常(exception)... 我无法从我这边发现错误...... 任何人都可以对此提出建议.. FATAL EXCEPTION: main E/AndroidRu
这就是我的 Admob 横幅的实现方式。 在 Layout.xml 中 在 AdActivity.java 中 private void initBannerViewGroup()
我想在同一事件中同时展示横幅广告和插页式广告。但我不确定这是否会违反 Google admob 政策,因为当显示插页式广告时,它会覆盖横幅广告。 谢谢。 最佳答案 这是允许的。事实上,建议您这样做以增
我是一名优秀的程序员,十分优秀!