当我运行应用程序时,它给出以下错误
incompatible types: <anonymous OnClickListener> cannot be converted to Context
InterstitialAd.load(this,ForexScalping.this.getString(R.string.main_inter), adRequest,
我仍然是新的代码,所以我没有线索。这是java文件
public class ForexScalping extends AppCompatActivity {
Button button2;
private InterstitialAd mInterstitialAd;
public void onBackPressed()
{
super.onBackPressed();
if (mInterstitialAd != null)
{
mInterstitialAd.show(ForexScalping.this);
return;
}
finish();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_forex_scalping);
this.button2 = findViewById(R.id.button2);
button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final ProgressDialog pd = new ProgressDialog(ForexScalping.this);
pd.setCancelable(false);
pd.setMessage("Loading...");
pd.show();
AdRequest adRequest = new AdRequest.Builder().build();
InterstitialAd.load(this,ForexScalping.this.getString(R.string.main_inter), adRequest,
new InterstitialAdLoadCallback() {
@Override
public void onAdLoaded(@NonNull InterstitialAd interstitialAd) {
// The mInterstitialAd reference will be null until
// an ad is loaded.
mInterstitialAd = interstitialAd;
mInterstitialAd.show(ForexScalping.this);
}
我试过将View.OnClicklistener添加到公共对象中,但它仍然会带来同样的错误。是的,我试过了所有与此相关的错误的答案。
1条答案
按热度按时间gwo2fgha1#
从InterstitialAd.load(this,外汇交易代码.this)中删除this。获取带有外汇交易代码.this字符串