Reputation: 2060
I want to declare something like this:
private <Fragment extends MyInterface> fragment;
because I want this fragment to be able to be set to a variety of different self-made Fragment objects that all implement MyInterface.
But it doesn't let me do this.
Is there a way to declare such a Fragment?
Upvotes: 1
Views: 185
Reputation: 116
I think what you're looking for is this:
public interface MyFragmentInterface {
}
public class MyFragment extends Fragment implements MyFragmentInterface {
}
Now to declare a variable:
private MyFragmentInterface fragment;
Upvotes: 2