android 入门学习笔记 Button 常用的弹窗效果code

/*取得 Button对象*/ mButton1 = (Button) findViewById(R.id.myButton1); mButton1.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub new AlertDialog.Builder(EX04_26.this) /*弹出窗口的最上头文字*/ .setTitle(R.string.app_about) /*设置弹出窗口的图式*/ .setIcon(R.drawable.hot) /*设置弹出窗口的信息*/ .setMessage(R.string.app_about_msg) .setPositiveButton(R.string.str_ok, new DialogInterface.OnClickListener() { public void onClick (DialogInterface dialoginterface, int i) { finish();/*关闭窗口*/ } } ).setNegativeButton(R.string.str_no, new DialogInterface.OnClickListener() { /*设置跳出窗口的返回事件*/ public void onClick(DialogInterface dialoginterface, int i) { } } ).show(); } });

 

这个是两个按钮的 setPositiveButton 和 setNegativeButton,如果是三个按钮的,中间的是setNeutralButton
 

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/df2ba60eedd7bc728951442505d523fd.html