介绍
怎么在Android应用中利用控件实现一个对话框功能?相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。
1,自定义提示对话框
DialogM.Builder builder =, new DialogM.Builder (DialogMActivity.this) ,,,.setTitle(“发现新版本V5.4.1") ,,,.setContent (“Version5.4.1 \ n【更新默认表情】——同步最新表情,聊天更有趣\ n", + ,,,,,,,,【资料卡大升级】——全新视觉设计,增加陌生人来源信息\ n" + ,,,,,,,,【消息跳动优化】——鼠标悬浮在消息列表上时顺序不动,再也不怕点错啦\ n" + ,,,,,,,,【收藏预览升级】——完善图片浏览体验,优化网页预览效果\ n" + ,,,,,,,,【更多体验优化】——群成员列表宽度可调,优化天气定位策略,优化图片查看器“) ,,,.setStyle (DialogM.STYLE_TIP) ,,,.setPositiveButton(“更新“,,new DialogInterface.OnClickListener (), { ,,,,@Override ,,,,,public void onClick (DialogInterface 对话框,int 它),{ ,,,,,,,Toast.makeText (DialogMActivity.this,“submit",, Toast.LENGTH_SHORT),告诉(); ,,,,,,,dialog.dismiss (); ,,,,,} ,,,}) ,,,.setNegativeButton(“取消“,,new DialogInterface.OnClickListener (), { ,,,,@Override ,,,,,public void onClick (DialogInterface 对话框,int 它),{ ,,,,,,,Toast.makeText (DialogMActivity.this,“cancel",, Toast.LENGTH_SHORT),告诉(); ,,,,,,,dialog.dismiss (); ,,,,,} ,,,}); builder.create(),告诉();
2,自定义警告对话框
DialogM.Builder builder =, new DialogM.Builder (DialogMActivity.this) ,,,.setTitle (“Hello") ,,,.setTitleBackColor (getresource () .getColor (R.color.content)) ,,,.setTitleTextColor (getresource () .getColor (R.color.mainColor)) ,,,.setAlertButtonBackColor (getresource () .getColor (R.color.mainColor)) ,,,.setAlertButtonTextColor (getresource () .getColor (android.R.color.white)) ,,,.setCanceledOnTouchOutside(假) ,,,.setAlertButton(“确定“,,new DialogInterface.OnClickListener (), { ,,,,@Override ,,,,,public void onClick (DialogInterface 对话框,int 它),{ ,,,,,,,dialog.dismiss (); ,,,,,} ,,,}) ,,,.setContent (“landptf"); builder.create(),告诉();
3,默认提示对话框
DialogM.Builder builder =, new DialogM.Builder (DialogMActivity.this) ,,,.setContent (“landptf") ,,,.setStyle (DialogM.STYLE_TIP) ,,,.setPositiveButton (“submit",, new DialogInterface.OnClickListener (), { ,,,,@Override ,,,,,public void onClick (DialogInterface 对话框,int 它),{ ,,,,,,,Toast.makeText (DialogMActivity.this,“submit",, Toast.LENGTH_SHORT),告诉(); ,,,,,,,dialog.dismiss (); ,,,,,} ,,,}) ,,,.setNegativeButton (“cancel",, new DialogInterface.OnClickListener (), { ,,,,@Override ,,,,,public void onClick (DialogInterface 对话框,int 它),{ ,,,,,,,Toast.makeText (DialogMActivity.this,“cancel",, Toast.LENGTH_SHORT),告诉(); ,,,,,,,dialog.dismiss (); ,,,,,} ,,,}); builder.create(),告诉();
4,默认警告对话框
DialogM.Builder builder =, new DialogM.Builder (DialogMActivity.this) ,,,.setAlertButton (““,, new DialogInterface.OnClickListener (), { ,,,,@Override ,,,,,public void onClick (DialogInterface 对话框,int 它),{ ,,,,,,,dialog.dismiss (); ,,,,,} ,,,}) null null怎么在Android应用中利用控件实现一个对话框功能