Madvertise Callback Listener

时间:2011-12-08 18:11:58

标签: android eclipse admob

大家好我有一个问题我想切换广告,具体取决于可用的广告。 所以我得到了这个代码 `

public class ActivityMain extends Activity {
    /** Called when the activity is first created. */
     private MadvertiseView mMadView;
     private AdView mAdmView;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

    mAdmView = (AdView)findViewById(R.id.admad);
    mMadView = (MadvertiseView)findViewById(R.id.madad);

    mMadView.setMadvertiseViewCallbackListener(new MadvertiseViewCallbackListener() {
        @Override public void onLoaded(boolean success, MadvertiseView arg1) {
             if (success) {
                  if (mAdmView.getVisibility() == View.VISIBLE) {
                       mAdmView.setVisibility(View.GONE);
                  }
                  mMadView.setVisibility(View.VISIBLE);
             } else {
                  mMadView.setVisibility(View.GONE);
             }
        }
    });
}`

现在我得到2个错误,并且知道如何修复它...... 这是第一个: 新的MadvertiseView.MadvertiseViewCallbackListener(){}类型必须实现继承的抽象方法MadvertiseView.MadvertiseViewCallbackListener.onError(Exception)

这是第二个: 新的MadvertiseView.MadvertiseViewCallbackListener(){}类型必须实现继承的抽象方法MadvertiseView.MadvertiseViewCallbackListener.onIllegalHttpStatusCode(int,String)

我希望有人能帮助我。

1 个答案:

答案 0 :(得分:1)

您正在实施一个包含onLoadedonIllegalHttpStatusCodeonError三种方法的界面,所以只需在onLoaded方法下方添加:

@Override
public void onIllegalHttpStatusCode(int statusCode, String message) {
// TODO Auto-generated method stub
}

@Override
public void onError(Exception exception) {
// TODO Auto-generated method stub
}