Reputation: 1084
I've seen questions like this, but it's not exactly what I'm looking for.
I was following the tutorial on how to build an RSS Android parser and reader from here. Along the way, some code included importing fragmentactivity
and fragment
. Both imports failed. Experimentation showed me that when importing the fragment, it should be imported as
import android.app.fragment;
rather than
import android.support.v4.app.fragment;
which was in the code for this RSS reader.
Trying the same thing with
import android.app.fragmentactivity;
doesn't work, when it calls for
import android.support.v4.app.fragmentactivity;
Does anyone know why it's failing to import this properly? Reading the Android Documentation doesn't seem to help. Please let me know if I need to add anything! Thanks.
Upvotes: 3
Views: 1452
Reputation: 354
You have to import the appropriate Android Support Library. Google has a thoroughly written document here: https://developer.android.com/tools/support-library/setup.html
However, the setup is kind of different depending on your IDE (Eclipse, Android Studio, etc.) From my personal experience, Android Studio is the easiest to get started with the nasty build logistics.
Upvotes: 1
Reputation: 93561
The v4 support library backports the idea of fragments to 2.X devices that don't have them in the framework. If you want to use fragments and run on 2.X, you must use the support versions and never the built ins. If you don't care about 2.X, use the builtins. As for problems importing, did you link in the v4 support library? You need that library to use the support fragments.
Upvotes: 0