ボタンとイベントメカニズム付きのダイアログボックスを実現します.
に注意
ここのパラメータはgetApplicationContext()と書くことができません.さもないと間違いを報告します.
AlertDialog.Builder dialog= new AlertDialog.Builder(MainActivity.this)
ここのパラメータはgetApplicationContext()と書くことができません.さもないと間違いを報告します.
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AlertDialog.Builder dialog= new AlertDialog.Builder(MainActivity.this);
dialog.setTitle(" ");
dialog.setMessage(" ");
dialog.setIcon(R.drawable.abc_ab_stacked_solid_dark_holo);
dialog.setPositiveButton(" ", new OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
Toast.makeText(getApplicationContext(), " ", 10).show();
}
});
dialog.setNegativeButton(" ", new OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
Toast.makeText(getApplicationContext(), " ", 10).show();
}
});
dialog.setNeutralButton(" ", new OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
Toast.makeText(getApplicationContext(), " ", 10).show();
}
});
dialog.show();
}