我在旧帖子上遇到了类似的问题..纠正了它们。仍然遇到强制关闭问题。请帮忙。
以下哪项是正确的?
Button continueButton = (Button) findViewById(R.id.continue_button);
或者
View continueButton = findViewById(R.id.continue_button);
他们之间有什么区别?
package org.example.sudoku;
import android.os.Bundle;
import android.view.View.OnClickListener;
import android.app.Activity;
import android.view.Menu;
import android.widget.Button;
public class Sudoku extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button continueButton = (Button) findViewById(R.id.continue_button);
continueButton.setOnClickListener((OnClickListener) this);
Button aboutButton = (Button)findViewById(R.id.about_button);
aboutButton.setOnClickListener((OnClickListener) this);
Button newButton = (Button)findViewById(R.id.new_game_button);
newButton.setOnClickListener((OnClickListener) this);
Button exitButton = (Button)findViewById(R.id.exit_button);
exitButton.setOnClickListener((OnClickListener) this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}