1

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?

1 Answer 1

5

More than likely, you're importing either Fragment or FragmentTransaction from the support library and the other from the non-support library. Make sure any Fragment pieces you import are all from the same place. I've had similar problems with fragments.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks so Much! Now works fine. The support library should be updated to avoid these absurd issues.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.