Я только что добавил add к своему приложению, но в тот момент, когда я запускаю его, я получаю усилие рядом с моим телефоном, и логкат отсутствует. Я никогда не заявлял об этом в своем XML, но я не думаю, что мне нужно ...
Вот адмоб.java:
package isaac.n;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ViewFlipper;
import com.google.ads.*;
public class admob extends Activity {
private AdView adView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Create the adView
adView = new AdView(this, AdSize.BANNER, "a14f725ebadc0f2");
// Lookup your LinearLayout assuming it’s been given
// the attribute android:id="@+id/mainLayout"
LinearLayout layout = (LinearLayout)findViewById(R.layout.main);
// Add the adView to it
layout.addView(adView);
// Initiate a generic request to load it with an ad
adView.loadAd(new AdRequest());
}
@Override
public void onDestroy() {
if (adView != null) {
adView.destroy();
}
super.onDestroy();
}
}
и вот main.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/gray3" >
<ImageView
android:id="@+id/imageView3"
android:layout_width="163dp"
android:layout_height="163dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="30dp"
android:src="@drawable/calc" />
<Button
android:id="@+id/button3"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="@color/red"
android:text="@string/Board"
android:textColor="@color/white"
android:textSize="30px"
android:textStyle="bold" />
<Button
android:id="@+id/button10"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_alignLeft="@+id/imageView3"
android:layout_marginLeft="16dp"
android:layout_marginTop="50dp"
android:background="@null" />
<ImageView
android:id="@+id/imageView4"
android:layout_width="190dp"
android:layout_height="190dp"
android:layout_below="@+id/imageView3"
android:layout_marginTop="33dp"
android:layout_toLeftOf="@+id/imageView3"
android:maxHeight="150dp"
android:maxWidth="150dp"
android:src="@drawable/white1" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="125dp"
android:layout_height="125dp"
android:layout_alignBottom="@+id/imageView4"
android:layout_alignLeft="@+id/button10"
android:layout_marginBottom="28dp"
android:src="@drawable/remin1" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="125dp"
android:layout_height="125dp"
android:layout_alignBottom="@+id/imageView3"
android:layout_alignRight="@+id/imageView4"
android:layout_marginBottom="18dp"
android:layout_marginRight="16dp"
android:src="@drawable/notes" />
<Button
android:id="@+id/button1"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_alignRight="@+id/imageView2"
android:layout_alignTop="@+id/imageView2"
android:background="@null" />
<Button
android:id="@+id/button2"
android:layout_width="170px"
android:layout_height="170px"
android:layout_alignRight="@+id/imageView1"
android:layout_alignTop="@+id/imageView1"
android:background="@null" />
<Button
android:id="@+id/button4"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_alignBottom="@+id/imageView1"
android:layout_alignRight="@+id/imageView2"
android:background="@null" />
</RelativeLayout>
Вот мой манифест:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="isaac.n"
android:versionCode="2"
android:versionName="1.1" >
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.READ_CALENDAR"></uses-permission>
<uses-permission android:name="android.permission.WRITE_CALENDAR"></uses-permission>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:icon="@drawable/ic_launcher1"
android:label="@string/app_name" >
<activity android:name="com.admob.android.ads.admob"/>
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation"/>
<activity
android:name="isaac.n.IzzynActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="isaac.n.notes"
android:label="@string/notes"
android:screenOrientation="portrait"></activity>
<activity android:name="isaac.n.FingerPaint"
android:label="WhiteBoard"
android:screenOrientation="portrait"></activity>
<activity
android:name="isaac.n.calculator"
android:label="@string/calculator"
android:screenOrientation="portrait"></activity>
<activity android:name=".main1"
android:label="@string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>