I need to use a fragment container to show various different fragments, so I'm tring to use FragmentManager
and FragmentTransaction
but If I try to use the following code Eclipse give me the error FragmentTransaction is not applicable for the argument PieFragment in transaction.add(...)
line
FragmentTransaction transaction = manager.beginTransaction();
transaction.add(R.id.fragmentcontainer1, new PieFragment());
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
transaction.commit();
break;
My custom Fragment is this
public class PieFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View v = inflater.inflate(R.layout.fragment_piegraph, container,
false);
PieGraph pg = (PieGraph) v.findViewById(R.id.piegraph);
...
pg.setOnSliceClickedListener(new OnSliceClickedListener() {
@Override
public void onClick(int index) {
}
});
return v;
}
public void updateDisplay() {
// TODO Auto-generated method stub
}
}
The Fragment layout
<com.mypackage.graphlibrary.PieGraph
android:layout_width="match_parent"
android:layout_height="200dp"
android:id="@+id/piegraph"/>
How could I solve this problem?