Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
299 views
in Technique[技术] by (71.8m points)

java - MapView without MapActivity

I am writing this android application where in I have many activities that extend the Activity class. I also need an activity that uses MapView to show the Map along with a ListView in the screen (similar to rental house list where the houses are shown using pins on the map) Since I have a base class which extends the Activity class, all the other activities extend that base class. Only that particular screen which has the map needs to extend the MapActivity class. When I try doing that I am thrown a IllegalAccessError Exception.

Project setup - Android 2.1-update1 and GoogleAPI 2.1-update 1 both throw the same exception. The application is for a tablet.

I have made sure that I have the entry in the Manifest.

Any help would be much appreciated.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I don't think there is any way around this. A MapView will only work in a MapActivity and each MapActivity can only contain 1 MapView. I have run into similar problems when using a single Activity base class. Try moving some of the code from your base class into either static methods or into a composite design pattern to cut down on the amount of copied code. It should be possible to design your code so that only the onX methods need to be duplicated between your base Activity and your MapActivty.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...