Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/343.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
Javascript 迁移到新的google play服务库_Javascript_Java_Android_Google Play Services - Fatal编程技术网

Javascript 迁移到新的google play服务库

Javascript 迁移到新的google play服务库,javascript,java,android,google-play-services,Javascript,Java,Android,Google Play Services,大家好,我是java新手, 我想用新的google play服务库更新我的应用程序,我已经编辑了xml布局文件,但是src文件显示了以下错误: AdListener类型不能是AdManager的超级接口;超级接口必须是接口 创建时adview必须位于公共void上 以下是代码的一部分: public class GameActivity extends Activity implements AdListener { ..... ...... private InterstitialAd

大家好,我是java新手, 我想用新的google play服务库更新我的应用程序,我已经编辑了xml布局文件,但是src文件显示了以下错误:

  • AdListener类型不能是AdManager的超级接口;超级接口必须是接口
创建时adview必须位于公共void上

以下是代码的一部分:

public class GameActivity extends Activity implements AdListener {
.....
......

private InterstitialAd interstitial;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.game);


    getWindow().getDecorView().setBackgroundResource(R.drawable.background_ingame);
    //init sound effects
    Helper.InitSounds(this, new String[]{"click", "correct", "wrong", "tip"});
    //initialization of all needed views
    initViews();
    //loading first image into image_view
    loadImage(images[cur_image]);
    //saving name of this image
    correct_answer = getUpperNameWithoutExtensionAndSpaces(images[cur_image]);
    //generating letter and answer buttons for current image name
    fillLetterButtons(correct_answer);
    generateAnswerButtons(getNameWithoutExtension(images[cur_image]));
}

void generateNewLevel() {
    initLinkingAndTipLists();
    cur_image++;    
    if (cur_image % 2 == 0)
        interstitial.loadAd(new AdRequest());
    loadImage(images[cur_image]);
    money += 15;
    money_text.setText("Money" + ": $" + money);
    guess_text.setText("Correct" + ": " + cur_image + "/" + images.length);
    letters_in_answer = 0;
    correct_answer = getUpperNameWithoutExtensionAndSpaces(images[cur_image]);
    fillLetterButtons(correct_answer);
    generateAnswerButtons(getNameWithoutExtension(images[cur_image]));
}

void initLinkingAndTipLists() {
    link_list = new ArrayList<Point>();
    tip_list = new ArrayList<Boolean>();
    for (int i = 0; i < 3 * letters_count; i++) {
        link_list.add(i, new Point(0, 0));
        tip_list.add(i, false);
    }
}

void initViews() {
    check_toast = new Toast(this);
    tip_toast = new Toast(this);
    tip_button = (ImageButton) findViewById(R.id.tip_button);
    RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) tip_button.getLayoutParams();
    lp.width = tip_button_size.x;
    lp.height = tip_button_size.y;
    tip_button.setLayoutParams(lp);
    tip_button.setBackgroundResource(tip_button_background_id);
    tip_button.setOnTouchListener(new View.OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                getTip();
                tip_button.setAlpha(128);
            }
            if (event.getAction() == MotionEvent.ACTION_UP) {
                tip_button.setAlpha(255);
            }
            return false;
        }
    });
    main_layout = (LinearLayout) findViewById(R.id.main_layout);
    answer_line = new LinearLayout[3];
    answer_line[0] = (LinearLayout) findViewById(R.id.answer_line_1);
    answer_line[1] = (LinearLayout) findViewById(R.id.answer_line_2);
    answer_line[2] = (LinearLayout) findViewById(R.id.answer_line_3);
    letter_line = new LinearLayout[3];
    letter_line[0] = (LinearLayout) findViewById(R.id.letter_line_1);
    letter_line[1] = (LinearLayout) findViewById(R.id.letter_line_2);
    letter_line[2] = (LinearLayout) findViewById(R.id.letter_line_3);
    image = (ImageView) findViewById(R.id.question_image);
    setOnImageClickListener();
    check_button = (Button) findViewById(R.id.check_answer_button);
    check_button.setText("CHECK ANSWER");
    setOnCheckAnswerButtonClickListener();
    save = getSharedPreferences("SAVE_GAME", 0);
    editor = save.edit();
    if (save.contains("continue") && save.getBoolean("continue", false)) {
        images = save.getString("images", null).replaceAll("\'", "").split(",");
        cur_image = save.getInt("currentImage", 0);
        money = save.getInt("money", 0);
        for (int i = 0; i < images.length; i++) {
            System.out.println(images[i]);
        }
    } else {
        images = ShuffleImages(getImagesFromAssets());
        cur_image = 0;
        money = 40;
    }
    guess_text = (TextView) findViewById(R.id.guess_text);
    guess_text.setTypeface(Typeface.SERIF);
    guess_text.setTextSize(Helper.getScreenSize().x / 25);
    guess_text.setText("Correct" + ": " + cur_image + "/" + images.length);
    money_text = (TextView) findViewById(R.id.money_text);
    money_text.setTypeface(Typeface.SERIF);
    money_text.setTextSize(Helper.getScreenSize().x / 25);
    money_text.setText("Money" + ": $" + money);
    initLinkingAndTipLists();
    //load Admob Ads
      AdView adView = (AdView) this.findViewById(R.id.adView);
      adView.loadAd(new AdRequest());
    //init interstetial Ads
      interstitial = new InterstitialAd(this, "ca-app-pub-xxxxxxxx");
      AdRequest adReq = new AdRequest();
      interstitial.loadAd(adReq);
      interstitial.setAdListener(this);
}

String[] getImagesFromAssets() {
    String[] img_files = null;
    try {
        img_files = getAssets().list("pictures");
    } catch (IOException ex) {
        Logger.getLogger(GameActivity.class
                .getName()).log(Level.SEVERE, null, ex);
    }
    return img_files;
}
公共类GameActivity扩展活动实现AdListener{
.....
......
私人间质;
@凌驾
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.game);
getWindow().getDecorView().setBackgroundResource(R.drawable.background\u ingame);
//初始音效
InitSounds(这是一个新字符串[]{“单击”、“更正”、“错误”、“提示”});
//初始化所有需要的视图
initViews();
//将第一个图像加载到图像视图中
loadImage(图像[cur_image]);
//正在保存此图像的名称
correct_answer=GetUpperName不带扩展名和空格(images[cur_image]);
//为当前图像名称生成字母和答案按钮
填写字母按钮(正确答案);
生成swerbuttons(getNameWithoutExtension(images[cur_image]);
}
void generateNewLevel(){
initLinkingAndTipLists();
cur_image++;
如果(当前图像%2==0)
间质性loadAd(newadrequest());
loadImage(图像[cur_image]);
货币+=15;
money_text.setText(“money”+:$”+money);
guess_text.setText(“Correct”+:“+cur_image+”/“+images.length”);
答案中的字母=0;
correct_answer=GetUpperName不带扩展名和空格(images[cur_image]);
填写字母按钮(正确答案);
生成swerbuttons(getNameWithoutExtension(images[cur_image]);
}
void initLinkingAndTipLists(){
link_list=new ArrayList();
tip_list=new ArrayList();
对于(int i=0;i<3*个字母\u计数;i++){
链接列表。添加(i,新点(0,0));
提示列表。添加(i,false);
}
}
void initViews(){
选中_toast=新的toast(此);
tip_toast=新的toast(本);
tip_按钮=(ImageButton)findViewById(R.id.tip_按钮);
RelativeLayout.LayoutParams lp=(RelativeLayout.LayoutParams)提示按钮。getLayoutParams();
lp.width=尖端按钮尺寸x;
lp.height=尖端按钮尺寸y;
提示按钮。设置布局参数(lp);
提示按钮。设置背景资源(提示按钮背景id);
提示按钮.setOnTouchListener(新视图.OnTouchListener(){
公共布尔onTouch(视图v,运动事件){
if(event.getAction()==MotionEvent.ACTION\u向下){
getTip();
tip_按钮。设置Alpha(128);
}
if(event.getAction()==MotionEvent.ACTION\u UP){
tip_按钮。设置Alpha(255);
}
返回false;
}
});
main_布局=(LinearLayout)findViewById(R.id.main_布局);
答案=新的线性布局[3];
答案行[0]=(LinearLayout)findViewById(R.id.answer\u行[1];
答案行[1]=(线性布局)findViewById(R.id.answer\u行[2];
答案行[2]=(线性布局)findViewById(R.id.answer\u行[3];
字母_线=新的线性布局[3];
letter_line[0]=(LinearLayout)findViewById(R.id.letter_line_1);
letter_line[1]=(LinearLayout)findViewById(R.id.letter_line_2);
letter_line[2]=(LinearLayout)findViewById(R.id.letter_line_3);
image=(ImageView)findviewbyd(R.id.question\u image);
setOnImageClickListener();
检查按钮=(按钮)findViewById(R.id.check\u answer\u按钮);
check_button.setText(“检查答案”);
setOnCheckAnswerButtonClickListener();
save=getSharedReferences(“保存游戏”,0);
editor=save.edit();
if(save.contains(“continue”)&&save.getBoolean(“continue”,false)){
images=save.getString(“images”,null).replaceAll(“\”,”).split(“,”);
cur_image=save.getInt(“currentImage”,0);
money=save.getInt(“money”,0);
对于(int i=0;i
谢谢你的预支