[英](android.content.Context) in NotificationManagerCompat cannot be applied to
[英]cannot resolve context after importing android.content.Context; The Toast
這是我的代碼塊,我附上了一張圖片。 我不知道為什么“文本”和.show() 看起來是紅色的。
代碼塊:
private void setUpListViewListener() {
listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> adapterView, View view, int i, long l) {
Context context = getApplicationContext();
//Context context = getApplicationContext();
Toast.makeText(context, text: "Item Removed", Toast.LENGTH_LONG).show();
items.remove((i));
itemsAdapter.notifyDataSetChanged();
return true;
}
});
}
它的語法錯誤
語法是 -> Toast.makeText(context, text, duration).show();
Toast.makeText(getApplicationContext(), "Item Removed",Toast.LENGTH_LONG).show();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.