Take the 2-minute tour ×

So the scenario is

com.example.fragment1.FragmentSample.class com.example.fragment2.FragmentSample2.class ,,, com.example.main.MainActivity.class

so when my app start it will create fragmentsample as default and I like to call fragmentsample2 when I press the enter button in fragmentsample... but my code has always error how can i do this?? btw my mainactivity extend on activity... is this wrong like it should be FragmentAcitivity or is it ok?

share|improve this question
FragmentActivity is for compatability with pre-Honeycomb, so if you don't need to support older stuff Activity it is ok. If you've read the Google Fragment guide then you should post some code. –  IanB Jul 22 '13 at 10:05

1 Answer 1

In my experience, ADT is unhappy (doesn't recognize the R file) when Fragments don't belong to the same package as their Activity, so in your case you would need to move FragmentSample.java & FragmentSample2.java into com.example.main

If that doesn't solve your problem, you need to provide more detail on the error/s you're seeing.

share|improve this answer

Your Answer


