Android: how to import a class I have created?
I'm following the Hello, MapView documentation for Android.
I've followed it successfully most of the way through, including creating the HelloItemizedOverlay开发者_开发知识库 class, but when I get to this section:
List<Overlay> mapOverlays;
Drawable drawable;
HelloItemizedOverlay itemizedOverlay;
I suddenly start getting errors saying HelloItemizedOverlay cannot be resolved to a type
.
I guess this is because I haven't imported the class (the documentation doesn't generally include instructions for doing this), but how do I import the class that I have created in my project?
Move your class HelloItemizedOverlay.java down to the package where java file lies from where you are calling HelloItemizedOverlay
Using import: http://leepoint.net/notes-java/language/10basics/import.html
add the class to a jar file, then right click on your project navigate to BuildPath > Configure build path then on the libraries tab ad your jar. You can also try just dropping the .class file into the src folder on your hdd and refreshing your project.
精彩评论