用dialog做弹出框的时候,报错,如下图

感觉很奇怪,报的错误,我写在标题了,,解决方法,在OnClickListener前添加DialogInterface

例如取消,, alert.setButton(DialogInterface.BUTTON_NEGATIVE, "取消",new DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface dialog,int which) {
finish();
}
});

为什么这么改,

实际上就是一个错误,AlertDialog.setButton()里,第三个参数是一个OnClickListener,这个监听器类是DialogInterface里的,看异常说明,你那导入的类应该是View类里的OnClickListener。所以会出现类型异常。
 这是我百度的,别人的回答。
												

The method setButton(int, CharSequence, Message) in the type AlertDialog is not applicable for the a相关推荐

  1. The method setPositiveButton(int, DialogInterface.OnClickListener) in the type AlertDialog.Builder i

    The method setPositiveButton(int, DialogInterface.OnClickListener) in the type AlertDialog.Builder i ...

  2. The method setClass(Context, Class?) in the type Intent is not applicable for the arguments (GameV

    在当前短信内容的activity中写            Bundle bun = new Bundle();         bun.putString("message",  ...

  3. The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory的解决方法...

    最近又开始看jsp,那时候用的tomcat还是5的版本,我现在自己下的用的是tomcat6,在运行随书光盘的例子的时候,报了这样的错误: type Exception report message d ...

  4. Mapper method 'dao.xxx' has an unsupported return type

    前后端分离,前端上传数据,后台一直报这个Mapper method 'dao.xxx' has an unsupported return type错误,后来才发现是不需要返回值结果的,把返回值类型改 ...

  5. cannot use message (variable of type protoreflect.ProtoMessage) as type protoiface.MessageV1 in argu

    错误: cannot use message (variable of type protoreflect.ProtoMessage) as type protoiface.MessageV1 in ...

  6. Method cannot be marked @objc because the type of the parameter 1 cannot be represented in Objective

    错误:Method cannot be marked @objc because the type of the parameter 1 cannot be represented in Object ...

  7. The method setOnClickListener(View.OnClickListener) in the type View is not applicable

    开始学习 android 了,学习的是高明鑫老师的android视频教程(android视频教学). 学到第八讲时, 在写动态设置时报错: The method setOnClickListener( ...

  8. Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E>

    1 java 报错如下 Type safety: The method add(Object) belongs to the raw type List. References to generic ...

  9. Android NDK 【错误】The method loadLibrary(String) is undefined for the type Settings.Syste

    [错误]The method loadLibrary(String) is undefined for the type Settings.System [解决方法] 不要加入包import andr ...

最新文章

  1. C语言基础_函数指针
  2. 从功能测试到性能测试的转型之路
  3. 一次性动态绑定多个droplistdown
  4. 这些道理不懂,你注定就是穷打工的命!(转载)
  5. 中石油训练赛 - Spiral Matrix(找规律)
  6. java生成16位随机数_java中如何产生一个16位数字组成的随机字符串?谢谢各位了...
  7. php中修改元素值为5,php怎么改变元素数组的值
  8. 首次超过苹果!华为高端智能手机Q1国内市场出货量占48%
  9. vb取消文本框的粘贴功能
  10. L1-048 矩阵A乘以B-PAT团体程序设计天梯赛GPLT
  11. 虚拟化—用新的视角看IT
  12. 论.NET反射、委托与模式关系 zt- -
  13. Chrome免安装版制作
  14. python绘制3d点云_python – 来自点云的3D凸包
  15. 相片打印机原理_手机照片打印机的原理是什么 便携式照片打印机到底好不好...
  16. 小说阅读 (支持txt文本文件浏览)
  17. [附源码]java毕业设计网上宠物商店
  18. bootstrap 表格表头固定
  19. 基于Aforge的物体运动识别-入门篇
  20. reason:The server time zone value '???ú±ê×??±??' is unrecognized or represents more than one time zo

热门文章

  1. 2022-2028年中国数码摄像机市场投资分析及前景预测报告
  2. 2022-2028年中国集装箱涂料行业市场研究及前瞻分析报告
  3. 直方图_20210420
  4. CRF(条件随机场)与Viterbi(维特比)算法原理详解
  5. pytorch BiLSTM+CRF代码详解 重点
  6. seq2seq(1)- EncoderDecoder架构
  7. 超轻量AI引擎MindSpore Lite
  8. 基于TensorRT的BERT实时自然语言理解(下)
  9. PyTorch神经网络集成技术
  10. 客快物流大数据项目(四十九):开发环境初始化