开发者

Reducing duplication of code when using Activity and MapActivity

I can create an intermediate activity class like MyAppActivity, to contain common code used across my activities, but this obviously doesn't work if the app also needs to subclass MapActivity.

What's the solution? Options I see:

  • Move as many methods as possible to an ActivityUtils class (yuk)

  • Accept some duplication (yuk)

  • Subclass MapActivity, and use that class to subclass my actual activities. I'm not sure what the downside to this is. MapActivity doesn't seem to object if there's no MapView present. Ugly, but I suspect rather less ugly than duplicating lots of code which has a direct negat开发者_如何学运维ive impact on quality and maintenance.

This challenge also applies with PreferenceActivity.


It is not possible to use a common Helper class with static methods?

EDIT: ah maybe that's your first mentioned option

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜