我只尝试使用 2 个按钮进行测试,但是.. 最终没有工作,当它们被按下时它只会使应用程序崩溃,请告诉我它应该如何编码,并解释一下为什么?如果我知道它为什么会这样做,它将在以后对我有所帮助..这是我的代码
import com.google.ads.AdRequest;
import com.google.ads.AdSize;
import com.google.ads.AdView;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.view.View;
import android.view.View.OnClickListener;
public class Loading extends Activity {
Button button1;
Button xcheats;
Button pcheats;
protected Context context;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_loading);
button1 = (Button)findViewById(R.id.button1);
xcheats = (Button)findViewById(R.id.xcheats);
pcheats = (Button)findViewById(R.id.pcheats);
button1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent3 = new Intent(context, Manual.class);
startActivity(intent3);
}
});
xcheats.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent2 = new Intent(context, cheatsx.class);
startActivity(intent2);
}
});
}
public AdView adView;
public void onCreate2(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_loading);
String a1524e277372095 = null;
// Create the adView
adView = new AdView(this, AdSize.BANNER, a1524e277372095);
}
}