I try to build a method that change fragments in frame of activity. in one of the activities its going well, but in the second activity I've got Error. I've copied the code from the first activity and change the relevant things but in the second part I get error that said
Error:(65, 25) error: no suitable method found for add(int,MyCarView)
method FragmentTransaction.add(Fragment,String) is not applicable (argument mismatch; int cannot be converted to Fragment)
method FragmentTransaction.add(int,Fragment) is not applicable (argument mismatch; MyCarView cannot be converted to Fragment)
the code that working is:
fragment2 = new MyCarEdit();
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction transaction = fragmentManager.beginTransaction();
transaction.add(R.id.myCarFrame,fragment2);
transaction.commit();
and the second part of the code that NOT working is-
fragment3 = new MyCarView();
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction transaction2 = fragmentManager.beginTransaction();
transaction2.add**(R.id.myCarFrame2,fragment3)**;
transaction2.commit();
** = is the part that marked in error
like I said before, I already put this codes in other activity and they worked fine.
What's the problem here?