无法解析Toast的maketext()方法 [英] Cannot resolve maketext() method of Toast
本文介绍了无法解析Toast的maketext()方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
创建 Toast
Toast toast = Toast.makeText(this, text, duration);
我无法解析 Toast
的 makeText()
方法.
我收到此错误
java: no suitable method found for makeText(idtech.ESDN.ShapeData,java.lang.CharSequence,int)
method android.widget.Toast.makeText(android.content.Context,int,int) is not applicable
(actual argument idtech.ESDN.ShapeData cannot be converted to android.content.Context by method invocation conversion)
method android.widget.Toast.makeText(android.content.Context,java.lang.CharSequence,int) is not applicable
(actual argument idtech.ESDN.ShapeData cannot be converted to android.content.Context by method invocation conversion)
推荐答案
makeText的签名如下
The makeText's signature is the following
public static Toast makeText (Context context, CharSequence text, int duration)
第一个参数必须是上下文对象.您放置了 this
,但是 this
引用了此对象,它可能与 Activity
( Fragment
例如).
the first paramter has to be a context object. You put this
, but this
refers to this object and it can be something different from an Activity
(a Fragment
for instance).
这篇关于无法解析Toast的maketext()方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文