I'm trying to generify dynamic fragment instantiation:
private <F extends Fragment> void addFragment(F fragment) {
fragment.setArguments(new Bundle());
FragmentTransaction tx = getFragmentManager().beginTransaction();
tx.add(R.id.container, fragment);
tx.submit();
}
However, the compiler rejects tx.add(R.id.container, fragment) because there's no method signature for add(int, F)!
How do I make the add() method understand that F is indeed a Fragment?
Thanks in advance :)
0 comments:
Post a Comment