我收到一条我不明白的错误消息

时间:2018-12-13 11:59:30

标签: java android

尝试运行代码时收到错误消息

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

0 个答案:

没有答案