Generic class that extends class and implements interface

T must extend Fragment and implement SomeInterface

In that case you could declare SomeClass as the following:

public class SomeClass<T extends Fragment & SomeInterface>

That would require an object of type T to both extend Fragment and implement SomeInterface.

Further, using my T class, I want to create views, using T.getActivity() as Context.

I’m unfamiliar with Android, but if getActivity() is a public instance method declared in Fragment then will be entirely possible to call it on an instance of T, since the compiler will know all Ts must inherit that method.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)