public class Anime扩展了Activity {
private Button button;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
final CharSequence[] items = {"Red", "Green", "Blue"};
//Toast.makeText(Anime.this, "KKKKKKK", Toast.LENGTH_SHORT).show();
AlertDialog.Builder builder = new AlertDialog.Builder(Anime.this);
builder.setTitle("Pick a color");
builder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
Toast.makeText(Anime.this,"jjjjjjjjjjjjjjjjj", Toast.LENGTH_SHORT).show();
}
});
AlertDialog alert = builder.create();
}
});
}
}
我有代码只是为了显示AlertDialog。它不起作用。但是我发表评论的祝酒词很好用。不明白。
感谢show()! 它现在正在运作。
答案 0 :(得分:0)
您忘记显示对话框=)
alert.show();
答案 1 :(得分:0)
您应致电alert.show()
以显示提醒。
答案 2 :(得分:0)
您似乎忘记在警报上致电.show()
了。在AlertDialog alert = builder.create();
:
alert.show();