android dialog
1.提示框
AlertDialog.Builder builder = new AlertDialog.Builder(Activity.this); builder.setTitle("确认" ) ; builder.setMessage("这是一个简单消息框" ) ; builder.setPositiveButton("是" , null ); builder.show();
1.选择对话框
DialogInterface.OnClickListener dialogOnclicListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case Dialog.BUTTON_POSITIVE: break; case Dialog.BUTTON_NEGATIVE: break; } } }; AlertDialog.Builder builder = new AlertDialog.Builder(BarJudgeActivity.barJudgeActivity); builder.setIcon(R.mipmap.ic_launcher); builder.setTitle("对话框"); builder.setMessage("确认删除本条数据?"); builder.setPositiveButton("删除", dialogOnclicListener); builder.setNegativeButton("不删", dialogOnclicListener); builder.create().show(); }
2.列表对话框
final String items[] = {"A类", "B类", "C类", "二级品","三级品","待判"}; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("选择默认质量等级"); builder.setIcon(R.mipmap.ic_launcher); builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); tvChooseBarQualityLevel.setText(items[which]); } }); builder.create().show();