I have the following code:
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.Fragment;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_exercises_list);
List<Fragment> fList = new Vector<Fragment>();
fList.add(Fragment.instantiate(this, "All"));
which is a fatal exception. If i remove line fList.add(Fragment.instantiate(this, "All"));, it’s fine. So what’s happening? I have no idea how to use fragments so I’m guessing my problem is a nooby one.
If your
Fragmentis a nested inner class, make sure you have declared it to be apublic static class. Likewise, make sure theFragmentis namedAll.That being said, I hope you know what you are doing, because I can’t imagine a scenario in which I would store a
VectorofFragments. At the very least you should use anArrayListinstead.Also, you should post the exact error message you are getting, along with the rest of your logcat output.