尝试运行代码时收到错误消息
Attempt to invoke virtual method 'android.view.Window$Callback android.view.Window.getCallback()' on a null object reference
代码如下:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_the_game);
Button l = (Button) findViewById(R.id.Edit);
l.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(theGame.this, EditWords.class);
startActivity(i);
}
});
这是EditWords.java的代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_edit_words);
Button l = (Button) findViewById(R.id.add);
l.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(EditWords.this, AddWord.class);
startActivity(i);
}
});
Button x = (Button) findViewById(R.id.delete);
l.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(EditWords.this, DeleteWord.class);
startActivity(i);
}
});
Button b = (Button) findViewById(R.id.Back3);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {Intent i = new Intent(EditWords.this, theGame.class);
startActivity(i);
}
});
}
}