構建對話框我想添加監聽器,但應用程序崩潰。什麼是錯誤的?在對話框中的按鈕上設置點擊監聽器時,應用程序崩潰...
private void Info(){
textview = (TextView) findViewById(R.id.textView1);
LayoutInflater li = LayoutInflater.from(this);
View view = li.inflate(R.layout.info, null);
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(view).create().show();
buttonInfo = (Button)findViewById(R.id.buttonInfo);
buttonInfo.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
}
});
請分享崩潰日誌...和你是如何調用這個info()方法... –
如果你的按鈕佈局信息.xml你需要做buttonInfo =(Button)view.findViewById(R.id.buttonInfo); –