如何添加Admob广告/ Google移动广告?

时间:2014-08-10 11:43:13

标签: android admob ads banner adbannerview

这是我的第一个活动,我正在尝试插入横幅,但我不能。 我正在遵循本指南https://developers.google.com/mobile-ads-sdk/docs/admob/fundamentals?hl=it#play,但我很难完全理解它 任何人都可以给我建议或指导吗?

MainActivty

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;

public class MainActivity extends ActionBarActivity implements OnClickListener {

Button Episodi, Istruzioni, Sb;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //creazione fullscreen activity
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_main);
    //rimozione action bar
    if (Build.VERSION.SDK_INT < 11){
        getSupportActionBar().hide(); 
    }


    Episodi = (Button) findViewById(R.id.episodi);
    Istruzioni = (Button) findViewById(R.id.istruzioni);
    Sb = (Button) findViewById(R.id.Segnalaci_un_bug);
    Episodi.setOnClickListener(this);
    Istruzioni.setOnClickListener(this);
    Sb.setOnClickListener(this);

 }


public void onClick(View v) {

    switch(v.getId()){
    case R.id.episodi:
        Intent stagioni = new Intent(MainActivity.this,StagioniActivity.class);
        startActivity(stagioni);
        break;
    case R.id.istruzioni:
        Intent istruzioni = new Intent(MainActivity.this,IstruzioniActivity.class);
        startActivity(istruzioni);
        break;
    case R.id.Segnalaci_un_bug:
        Intent segnalabug = new Intent(MainActivity.this,SegnalaBugActivity.class);
        startActivity(segnalabug);
        break;
    }

}
}

MainActivity XML

<?xml version="1.0"?>
<FrameLayout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0c0c0c"
tools:context="com.example.prova.MainActivity"
tools:ignore="MergeRootFrame" >

<LinearLayout 
    android:layout_height="fill_parent" 
    android:layout_width="fill_parent" 
    android:orientation="vertical" 
    android:layout_gravity="center|top">

<ImageView 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:src="@drawable/homecaceracafe" 
    android:adjustViewBounds="true"/>

<Button
    android:id="@+id/episodi"
    android:layout_width="270dp"
    android:layout_height="60dp"
    android:layout_gravity="center"
    android:background="@drawable/bottonehome"
    android:text="Episodi"
    android:textSize="20sp" />

<Button
    android:id="@+id/istruzioni"
    android:layout_width="270dp"
    android:layout_height="60dp"
    android:layout_gravity="center"
    android:background="@drawable/bottonehome"
    android:text="Istruzioni"
    android:textSize="20sp" />

<Button
    android:id="@+id/Segnalaci_un_bug"
    android:layout_width="270dp"
    android:layout_height="60dp"
    android:layout_gravity="center"
    android:background="@drawable/bottonehome"
    android:text="Segnalaci un bug"
    android:textSize="20sp" />

0 个答案:

没有答案