迁移到新的谷歌播放服务库

时间:2016-07-14 01:48:43

标签: javascript java android google-play-services

Hii m java in new everyone, 我想用新的google play服务lib更新我的应用程序,我编辑了xml布局文件,但是src文件显示了我的错误:

  • AdListener类型不能是AdManager的超级接口;超级接口必须是接口

adview必须在onCreate上的公共空白?

这是代码的一部分:

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;
}

谢谢您的提前!

0 个答案:

没有答案