当前位置: 代码迷 >> Android >> android中setNegativeButton跟setNeutralButton的区别是什么
  详细解决方案

android中setNegativeButton跟setNeutralButton的区别是什么

热度:54   发布时间:2016-05-01 11:46:03.0
android中setNegativeButton和setNeutralButton的区别是什么?
只是在android的alertDialog中封装好的一些Button 这些Button和普通的Button没有任何区别,可以写任意的方法,只是命名上的不同,一般有三个 Button:PositiveButton,NegativeButton,NeutralButton。从名字可以看的出来,代表确定,否定,和中 立,其实三个Button可以写你任意的方法,只是位置上的不同而已,确定Button一般靠左,这是阅读习惯。本质上都是三个Button并没有很大的 区别,也许可能NegativeButton里面写了dismiss方法,这些我并没有去深究。
在对话框中出现的位置不同,setNegativeButton设置的是出现在最右,一般把最右的button功能设置为“取消”,也就是调用dlg.dismiss()。
setNeutralButton一般用做“确认”
  相关解决方案