You should use ModelLoader.this instead.
Accessing this of outerclass from anonymous inner class where outerclass has a generic
-
14-06-2023 - |
Question
I have some code like this:
public class ModelLoader<T extends Model> {
public ArrayList<T> fromJson(JSONArray jsonObjects) {
// blah blah blah
}
public void getAll(final OnRequestCompleted<T> callback) {
client.get(endpoint, null, new JsonHttpResponseHandler() {
@Override
public void onSuccess(JSONArray resp) {
// I want to call the fromJson method here
}
});
}
}
I have seen in various places that I can use OuterClass.this
, which in this case would be ModelLoader<T>.this
but that gives me syntax error.
How can I do this?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow