Eclipse: autocompletion and support lib(?)


#1

Hi!

I have medium-sized problem with this chapter: my autocompletion doesn’t work properly, for example when I type:

Fragment fragment = fm then after I press dot I see:

I googled a bit, and it seems like this problem arises when there is no source for appropriate functions. Therefore, how do I add it?


#2

Check your imports, I used autoImport at one point and it appeared that it picked up the native android fragment manager not the support library. I had to go back and fix the include, and then everything cleared out.


#3

Later versions of the SDK also have the option to download the source. That should also add the information you’re looking for - it may require an Eclipse restart.


#4

The proliferation of Android OS versions has a whole chapter devoted to it in the book, but the very next chapter on Fragments doesn’t mention that all of the automatically included import statements are going to be incorrect - instead of:

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;

we will get import statements that do not include the support library. The only way to get the right files w/o actually knowing what to import is to delete, say, “import android.app.FragmentManager” and then eclipse -> organize imports, and then select from the two choices presented to us. Repeat.