トーストを別のクラスからポップアップする方法を質問するには、多くの質問があります。アクティビティ以外のクラスでコンテキストが必要
私はwebViewClientを拡張しており、エラーなどのロードに関するメッセージをトーストでポップアップする必要がありますが、コンテキストを定義できないようです。
public class MyAppWebViewClient extends WebViewClient {
private static Context context;
public MyAppWebViewClient(Context c) {
context = c;
}
public static void popup(String message){
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
}
popup("Hello World")
}
そして、これは誤りです:
Error:(301, 34) error: constructor MyAppWebViewClient in class MyAppWebViewClient cannot be applied to given types;
required: Context
found: no arguments
reason: actual and formal argument lists differ in length
私が間違っているのは何?
どのようなコードがエラーを起こしますか? –
@Blackbelt - 助けてくれてありがとう、私はあなたが示唆したようにしてsuper()を追加しました。最初の行はエラーですが、エラーは同じです。 – crankshaft