![](/img/trans.png)
[英]The method sendKeys(CharSequence...) in the type WebElement is not applicable for the arguments (int)
[英]Android: The method makeText(Context, CharSequence, int) in the type Toast is not applicable for the arguments (ListViewAdapter, String, int)
我在过滤器类中使用吐司。 这是它的代码
public void filter(String charText) {
charText = charText.toLowerCase(Locale.getDefault());
expressionlist.clear();
if (charText.length() == 0) {
expressionlist.addAll(arraylist);
} else {
for (Expression wp : arraylist) {
if (wp.getWord().toLowerCase(Locale.getDefault())
.contains(charText)) {
expressionlist.add(wp);
}
}
if(expressionlist.size() == 0){
Toast toast = Toast.makeText(this, "No match found", Toast.LENGTH_LONG);
toast.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
toast.show();
// add all items of expressionlist
expressionlist.addAll(arraylist);
}
}
notifyDataSetChanged();
}
}
我收到错误makeText(Context, CharSequence, int)
Toast类型的方法makeText(Context, CharSequence, int)
不适用于参数(ListViewAdapter, String, int)
如何解决此问题?
您应该引用上下文,即getApplicationContext()
或传递ListViewAdapter的上下文。
上下文可以是Activity
或Fragment
Toast toast = Toast.makeText(context, "No match found", Toast.LENGTH_LONG);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.