我收到以下错误,我在教程中确实(afaik)作为一个人,但我仍然收到错误:“无法从类型对话框中对非静态方法 show() 进行静态引用”在“AlertDialog.节目();” “AlertDialog 无法解析或不是字段”在“AlertDialog.alertDialog = dialogBuilder.create();”
这是我的代码:
public Button paginanoua;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
paginanoua = (Button) findViewById(R.id.paginanoua);
paginanoua.setOnClickListener(this);
}
public void onClick(View view) {
ShowDialog();
}
private void ShowDialog() {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
dialogBuilder.setTitle("Pagina noua..");
dialogBuilder.setMessage("Sigur doriti o pagina noua?");
dialogBuilder.setPositiveButton("Da",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(),
"Am inceput o lista noua", Toast.LENGTH_SHORT)
.show();
}
});
dialogBuilder.setNegativeButton("Nu",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(),
"Ramanem la lista curenta", Toast.LENGTH_SHORT)
.show();
}
});
AlertDialog.alertDialog = dialogBuilder.create();
AlertDialog.show();
}
我做错了什么 ?