T
T
thatmaniscool2022-01-16 20:49:49
JavaScript
thatmaniscool, 2022-01-16 20:49:49

Is it possible to override a Java 11 anonymous class method?

There is an anonymous adapter class

public class MyAdapter extends ArrayAdapter<T> {
    pubic View getView(params){
       return view;
    }
}


Is it possible to override the getView method when declaring a class as anonymous?
example like this
return new MyAdapter (){
     public View getView(params){
          return customnizedView;
     }
  }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Kovalsky, 2015-11-03
@Kusmich

To begin with, you have some kind of recursion that is not very clear to me in the very first sentence of the question: "Json arrives in which, among other things, there is the date of the participants' performance. You need to compare this date with the date in json." Which one with which?)
Then I didn’t understand the contents of the objects: what is date and what is dataRel and is it the same date?
But in general, it does not matter, then everything will be simple.
I confess, I’m too lazy to invent a ready-made solution, but if you are satisfied with the outline, then it’s like this:
Dates can be converted to timestamp, somehow right off the bat it doesn’t turn out very correctly for me (when translating the parsed string back into a date, the time is an hour behind), but I feel a problem in binding in GMT, this is solvable. And already the timestamps are compared as ordinary numbers, I don’t see any further difficulties.
For example, like this:

a = new Date(Date.parse('Wednesday, November 04, 2015' + ' 13:30'))
b = new Date(Date.parse('Wednesday, November 04, 2015' + ' 11:30'))

if (a > b) {
    // что-нибудь натворим тут
}

And since you say that you can correct json, then shove the timestamp itself there, then in general the algorithm will be transparent.
If no one answers you by tomorrow, then in the morning I will make a complete solution based on the information available.

D
Denis Zagaevsky, 2022-01-16
@thatmaniscool


public class MyAdapter extends ArrayAdapter<T> {
    pubic View getView(params){
       return view;
    }
}


This class is not anonymous.
return new MyAdapter (){
     public View getView(params){
          return customnizedView;
     }
  }

Yes, it can be done.
.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question