0

这是我在我看来如何使用它

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:isScrollContainer="true"
    android:overScrollMode="always"
    android:scrollbarAlwaysDrawVerticalTrack="true"
    android:scrollbarStyle="outsideOverlay"
    android:scrollbars="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:scrollbars="horizontal|vertical" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#7db121"
            android:orientation="vertical" >

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >

                <TextView
                    android:id="@+id/batmanDName"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:text="Name"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:textColor="#FFFFFF" />

                <ImageView
                    android:id="@+id/imageView1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:layout_alignParentTop="true"
                    android:src="@drawable/runswhite2" />
            </RelativeLayout>

            <TextView
                android:id="@+id/batDteam"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Team"
                android:textColor="#FFFFFF" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:paddingLeft="@android:dimen/app_icon_size"
            android:paddingRight="@android:dimen/app_icon_size"
            android:paddingTop="@android:dimen/app_icon_size" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:orientation="horizontal" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight=".90"
                    android:text="Runs" />

                <TextView
                    android:id="@+id/batmanDRuns"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight=".10"
                    android:text="Runs" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:orientation="horizontal" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight=".90"
                    android:text="Matches" />

                <TextView
                    android:id="@+id/batsmanDmatch"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight=".10"
                    android:text="matches" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:orientation="horizontal" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight=".90"
                    android:text="Innings" />

                <TextView
                    android:id="@+id/batsmanDInns"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight=".10"
                    android:text="Innings" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:orientation="horizontal" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight=".90"
                    android:text="High Score" />

                <TextView
                    android:id="@+id/batsmanDHighScore"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight=".10"
                    android:text="High Scores" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:orientation="horizontal" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight=".90"
                    android:text="Strike Rate" />

                <TextView
                    android:id="@+id/batsmanDSr"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight=".10"
                    android:text="strike Rate" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:orientation="horizontal" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight=".90"
                    android:text="Average" />

                <TextView
                    android:id="@+id/batDave"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight=".10"
                    android:text="Averege" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:orientation="horizontal" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight=".90"
                    android:text="100&apos;s" />

                <TextView
                    android:id="@+id/hundreds"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight=".10"
                    android:text="100s" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:orientation="horizontal" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight=".90"
                    android:text="50&apos;s" />

                <TextView
                    android:id="@+id/fifty"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight=".10"
                    android:text="50s" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:orientation="horizontal" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight=".90"
                    android:text="4&apos;s" />

                <TextView
                    android:id="@+id/batsman4s"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight=".10"
                    android:text="4s" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:orientation="horizontal" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight=".90"
                    android:text="6&apos;s" />

                <TextView
                    android:id="@+id/batsman6s"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight=".10"
                    android:text="6s" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:orientation="horizontal" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight=".90"
                    android:text="Ducks" />

                <TextView
                    android:id="@+id/bats0s"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight=".10"
                    android:text="Zeros" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:orientation="horizontal" >

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight=".90"
                    android:text="Un Beaten" />

                <TextView
                    android:id="@+id/batsnot"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight=".10"
                    android:text="not out" />
            </LinearLayout>
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:orientation="horizontal" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="                                      " />
        </LinearLayout>

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >

            <ImageView
                android:id="@+id/shareBat"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_alignParentTop="true"
                android:layout_marginRight="126dp"
                android:onClick="shareBat"
                android:src="@drawable/sharebtn" />

            <ImageView
                android:id="@+id/cricInfoBat"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_marginRight="24dp"
                android:layout_toLeftOf="@+id/shareBat"
                android:onClick="openCricInfo"
                android:src="@drawable/cricinfo" />

            <Button
                android:id="@+id/button1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignLeft="@+id/shareBat"
                android:layout_alignParentTop="true"
                android:layout_marginLeft="16dp"
                android:onClick="facebook"
                android:text="Facebook" />
        </RelativeLayout>

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >

            <com.google.ads.AdView
                android:id="@+id/adView"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_alignParentLeft="true"
                ads:adSize="SMART_BANNER"
                ads:adUnitId="a1508857970fc3c"
                android:gravity="center" />
        </RelativeLayout>
    </LinearLayout>

</ScrollView>

这是这个程序的痕迹

> null
Error
Mon Nov 26 22:59:43 PKT 2012
com.google.ads.AdView failed to instantiate.

java.lang.UnsupportedOperationException
at com.android.layoutlib.bridge.android.BridgeContext.getApplicationContext(BridgeContext.java:1272)
at com.google.ads.AdView.a(SourceFile:169)
at com.google.ads.AdView.a(SourceFile:366)
at com.google.ads.AdView.<init>(SourceFile:129)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback.instantiateClass(ProjectCallback.java:402)
at com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback.loadView(ProjectCallback.java:166)
at com.android.layoutlib.bridge.android.BridgeInflater.loadCustomView(BridgeInflater.java:205)
at com.android.layoutlib.bridge.android.BridgeInflater.createViewFromTag(BridgeInflater.java:133)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:83)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:702)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:86)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:702)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:86)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:702)
at android.view.LayoutInflater.inflate(LayoutInflater.java:479)
at android.view.LayoutInflater.inflate(LayoutInflater.java:367)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:324)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:321)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:325)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.RenderService.createRenderSession(RenderService.java:372)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.renderWithBridge(GraphicalEditorPart.java:1638)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.recomputeLayout(GraphicalEditorPart.java:1389)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.activated(GraphicalEditorPart.java:1163)
at com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditorDelegate.delegatePageChange(LayoutEditorDelegate.java:674)
at com.android.ide.eclipse.adt.internal.editors.common.CommonXmlEditor.pageChange(CommonXmlEditor.java:360)
at org.eclipse.ui.part.MultiPageEditorPart$2.widgetSelected(MultiPageEditorPart.java:290)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:234)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062
)at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:774)
at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:2743)
at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1429)
at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:257)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:620)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
at org.eclipse.equinox.launcher.Main.run(Main.java:1408)
at org.eclipse.equinox.launcher.Main.main(Main.java:1384)
4

1 回答 1

0

确保您AdActivity在清单文件中声明了:

<activity android:name="com.google.ads.AdActivity"
      android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
于 2012-11-26T21:15:59.013 回答