Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.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
admob添加的内容没有出现在android eclipse中请帮助_Android_Eclipse_Admob - Fatal编程技术网

admob添加的内容没有出现在android eclipse中请帮助

admob添加的内容没有出现在android eclipse中请帮助,android,eclipse,admob,Android,Eclipse,Admob,.java文件代码 package com.soundboard; import com.soundboard.SoundManager; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import com.google

.java文件代码

        package com.soundboard;

import com.soundboard.SoundManager;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import com.google.ads.*;

public class Soundboard extends Activity {
    private SoundManager mSoundManager;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        AdView adView = new AdView(this, AdSize.BANNER, "a14e2748a80b0ac");
        LinearLayout layout = (LinearLayout) findViewById(R.id.layout1);
        layout.addView(adView);
        adView.loadAd(new AdRequest());


                // Create the adView
                AdView adView = new AdView(this, AdSize.BANNER, a14e2748a80b0ac);
                // Lookup your LinearLayout assuming it’s been given
                // the attribute android:id="@+id/mainLayout"
                LinearLayout layout = (LinearyLayout)findViewById(R.id.mainLayout);
                // Add the adView to it
                layout.addView(adView);
                // Initiate a generic request to load it with an ad
                adView.loadAd(new AdRequest());
              }
            }




        mSoundManager = new SoundManager();
        mSoundManager.initSounds(getBaseContext());
        mSoundManager.addSound(1, R.raw.sound1);
        mSoundManager.addSound(2, R.raw.sound2);
        mSoundManager.addSound(3, R.raw.sound3);
        mSoundManager.addSound(4, R.raw.sound4);
        mSoundManager.addSound(5, R.raw.sound5);
        mSoundManager.addSound(6, R.raw.sound6);
        mSoundManager.addSound(7, R.raw.sound7);
        mSoundManager.addSound(8, R.raw.sound8);
        mSoundManager.addSound(9, R.raw.sound9);
        mSoundManager.addSound(10, R.raw.sound10);
        mSoundManager.addSound(11, R.raw.sound11);
        mSoundManager.addSound(12, R.raw.sound12);
        mSoundManager.addSound(13, R.raw.sound13);
        mSoundManager.addSound(14, R.raw.sound14);
        mSoundManager.addSound(15, R.raw.sound15);
        mSoundManager.addSound(16, R.raw.sound16);
        mSoundManager.addSound(17, R.raw.sound17);
        mSoundManager.addSound(18, R.raw.sound18);
        mSoundManager.addSound(19, R.raw.sound19);
        mSoundManager.addSound(20, R.raw.sound20);
        mSoundManager.addSound(21, R.raw.sound21);
        mSoundManager.addSound(22, R.raw.sound22);
        mSoundManager.addSound(23, R.raw.sound23);
        mSoundManager.addSound(24, R.raw.sound24);
        mSoundManager.addSound(25, R.raw.sound25);
        mSoundManager.addSound(26, R.raw.sound26);
        mSoundManager.addSound(27, R.raw.sound27);
        mSoundManager.addSound(28, R.raw.sound28);
        mSoundManager.addSound(29, R.raw.sound29);
        mSoundManager.addSound(30, R.raw.sound30);


        Button SoundButton1 = (Button)findViewById(R.id.sound1);
        SoundButton1.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        mSoundManager.playSound(1);

    }
});       
        Button SoundButton2 = (Button)findViewById(R.id.sound2);
        SoundButton2.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        mSoundManager.playSound(2);

    }
});    
        Button SoundButton3 = (Button)findViewById(R.id.sound3);
        SoundButton3.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        mSoundManager.playSound(3);

    }
});    
        Button SoundButton4 = (Button)findViewById(R.id.sound4);
        SoundButton4.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        mSoundManager.playSound(4);

    }
});    
        Button SoundButton5 = (Button)findViewById(R.id.sound5);
        SoundButton5.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        mSoundManager.playSound(5);

    }
});   
        Button SoundButton6 = (Button)findViewById(R.id.sound6);
        SoundButton6.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        mSoundManager.playSound(6);

    }
});    
        Button SoundButton7 = (Button)findViewById(R.id.sound7);
        SoundButton7.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        mSoundManager.playSound(7);

    }
});
  Button SoundButton8 = (Button)findViewById(R.id.sound8);
       SoundButton8.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        mSoundManager.playSound(8);

    }
 });    
        Button SoundButton9 = (Button)findViewById(R.id.sound9);
        SoundButton9.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        mSoundManager.playSound(9);

    }
});    
       Button SoundButton10 = (Button)findViewById(R.id.sound10);
       SoundButton10.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        mSoundManager.playSound(10);

    }
 });    
        Button SoundButton11 = (Button)findViewById(R.id.sound11);
        SoundButton11.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        mSoundManager.playSound(11);

    }
});    
        Button SoundButton12 = (Button)findViewById(R.id.sound12);
        SoundButton12.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        mSoundManager.playSound(12);

    }
});    
       Button SoundButton13 = (Button)findViewById(R.id.sound13);
       SoundButton13.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        mSoundManager.playSound(13);

    }
 });    
        Button SoundButton14 = (Button)findViewById(R.id.sound14);
        SoundButton14.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        mSoundManager.playSound(14);

    }
});    

        Button SoundButton15 = (Button)findViewById(R.id.sound15);
                SoundButton15.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                mSoundManager.playSound(15);

            }
        });
                Button SoundButton16 = (Button)findViewById(R.id.sound16);
                SoundButton16.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                mSoundManager.playSound(16);

            }
        });    
                Button SoundButton17 = (Button)findViewById(R.id.sound17);
                SoundButton17.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                mSoundManager.playSound(17);

            }
        });    
                Button SoundButton18 = (Button)findViewById(R.id.sound18);
                SoundButton18.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                mSoundManager.playSound(18);

            }
        });    
                Button SoundButton19 = (Button)findViewById(R.id.sound19);
                SoundButton19.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                mSoundManager.playSound(19);

            }
        });    
                Button SoundButton20 = (Button)findViewById(R.id.sound20);
                SoundButton20.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                mSoundManager.playSound(20);

            }
        });    
               Button SoundButton21 = (Button)findViewById(R.id.sound21);
                SoundButton21.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                mSoundManager.playSound(21);

            }
       });    
                Button SoundButton22 = (Button)findViewById(R.id.sound22);
                SoundButton22.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                mSoundManager.playSound(22);

            }
        });    
                Button SoundButton23 = (Button)findViewById(R.id.sound23);
                SoundButton23.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                mSoundManager.playSound(23);

            }
        });    
                Button SoundButton24 = (Button)findViewById(R.id.sound24);
                SoundButton24.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                mSoundManager.playSound(24);

            }
        });    
                Button SoundButton25 = (Button)findViewById(R.id.sound25);
                SoundButton25.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                mSoundManager.playSound(25);

            }
        });    
                Button SoundButton26 = (Button)findViewById(R.id.sound26);
                SoundButton26.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                mSoundManager.playSound(26);

            }
        });    
                Button SoundButton27 = (Button)findViewById(R.id.sound27);
                SoundButton27.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                mSoundManager.playSound(27);

            }
        });    
                Button SoundButton28 = (Button)findViewById(R.id.sound28);
                SoundButton28.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                mSoundManager.playSound(28);

            }
        });    
                Button SoundButton29 = (Button)findViewById(R.id.sound29);
                SoundButton29.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                mSoundManager.playSound(29);

            }
        });    
                Button SoundButton30 = (Button)findViewById(R.id.sound30);
                SoundButton30.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                mSoundManager.playSound(30);

            }
        });    

    }
}
我还包含了my.xml中的代码

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TableLayout
android:id="@+id/tablelayout1"
android:layout_width="312px"
android:layout_height="fill_parent"
android:orientation="vertical"
>

<Button
android:id="@+id/sound1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound button 1"
>
</Button>
<Button
android:id="@+id/sound2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound button 2"
>
</Button>
<Button
android:id="@+id/sound3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound button 3"
>
</Button>
<Button
android:id="@+id/sound4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound button 4"
>
</Button>
<Button
android:id="@+id/sound5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound button 5"
>
</Button>
<Button android:text="Sound Button 6" android:id="@+id/sound6" android:layout_height="wrap_content" android:layout_width="wrap_content"></Button>
<Button
android:id="@+id/sound7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sount Button 7"
>
</Button>
<Button
android:id="@+id/sound8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound button 8"
>
</Button>
<Button
android:id="@+id/sound9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound Button 8"
>
</Button>

<Button
android:id="@+id/sound10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound button 10"
>
</Button>
<Button
android:id="@+id/sound11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound button 11"
>
</Button>
<Button
android:id="@+id/sound12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound button 12"
>
</Button>
<Button
android:id="@+id/sound13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound button 13"
>
</Button>
<Button
android:id="@+id/sound14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound button 14"
>
</Button>
<Button
android:id="@+id/sound15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound button 15"
>
</Button>
<Button
android:id="@+id/sound16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound button 16"
>
</Button>
<Button
android:id="@+id/sound17"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound button 17"
>
</Button>
<Button
android:id="@+id/sound18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound button 18"
>
</Button>
<Button
android:id="@+id/sound19"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound button 19"
>
</Button>
<Button
android:id="@+id/sound20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound button 20"
>
</Button>
<Button
android:id="@+id/sound21"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound button 21"
>
</Button>
<Button
android:id="@+id/sound22"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound button 22"
>
</Button>
<Button
android:id="@+id/sound23"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound button 23"
>
</Button>
<Button
android:id="@+id/sound24"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound button 24"
>
</Button>
<Button
android:id="@+id/sound25"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound button 25"
>
</Button>
<Button
android:id="@+id/sound26"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound Button 26"
>
</Button>
<Button
android:id="@+id/sound27"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound button 27"
>
</Button>
<Button
android:id="@+id/sound28"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound button 28"
>
</Button>
<Button
android:id="@+id/sound29"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound button 29"
>
</Button>
<Button
android:id="@+id/sound30"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sound button 30"
>
</Button>
</TableLayout>
</LinearLayout>
我想我会给你一些截图,让它无痛

我在soundboard.java页面上看到了这三个错误。在这一点上,我只是试图操纵我的代码,以便没有错误,我可以尝试在模拟器中运行它

现在一行有3个错误

这条线上有多个标记 无法解析线性布局 一种类型 无法解析布局1,或者该布局已关闭 不是场 无法解析线性布局 一种类型 谁知道我做错了什么?谢谢

我只是试着遵循谷歌网站上熟悉的教程:


将SoundBoard类中的onCreate更改为:

public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  AdView adView = new AdView(this, AdSize.BANNER, "a14e2748a80b0ac");
  LinearLayout layout = (LinearLayout) findViewById(R.id.LinearLayout1);
  layout.addView(adView);
  adView.loadAd(new AdRequest());

  mSoundManager = new SoundManager();
  mSoundManager.initSounds(getBaseContext());

  // The rest of the soundManager code you've written
}
删除整个BannerExample类,其中包含admob代码,您只需要它一次,额外的括号用于关闭onCreate方法和类

您还需要导入LinearLayout,只需在eclipse中按ctrl+o或cmd+o,它就可以导入所需的类

您需要查看admob id的周围信息


我之所以使用R.id.LinearLayout1,是因为它是xml类中LinearLayout的名称,这就是mainLayout无法工作的原因。

您能否更具体地说明您遇到的问题?您是否将.jar文件添加到/lib目录,然后在Eclipse中的project explorer中刷新,然后右键单击.jar文件并选择addtobuildpath?我执行了属性>java构建路径>添加外部jar>并以这种方式选择了.jar并点击ok。然后它来到了屏幕截图中显示的当前位置。可以吗?或者我必须把它放在一个libs文件夹中吗?我试过用几种方法粘贴它,但总是出错:/I我不知道如何把它放进去,也不知道要去掉什么。内部类是指公共类吗?…只是不确定要去掉什么。非常感谢您的帮助,您能告诉我.java文件的外观吗?我将在上面发布代码。谢谢,文件很好,把整个BannerExample类处理掉就行了。然后将其替换为:AdView AdView=new AdView this,AdSize.BANNER,a14e2748a80b0ac;LinearLayout布局=LinearLayout findViewByIdR.id.layout1;layout.addViewadView;adView.loadad新地址;好的,我改变了密码。我仍然会出错:/I我已经编辑了帖子,并将新代码再次粘贴到.java文件区域。虽然我粘贴了您显示的代码,但无法添加括号{因为我不确定确切的位置,所以我也更新了我得到的错误,并在eclipse中发布了一个新的.java文件截图。谢谢!同一问题,您没有删除旧BannerExample类中的代码,我正在编辑我的答案,告诉您从哪里开始您的soundboard调用