I am developing a carpool application using our mCruiseOn platform. I have 2 activity's that I need to code, both the activity's have 90% the same code/flow and functionality. I can create a layout xml and just include it in both my layout's but how do I manage the code part of it. The intent is to not duplicate code, but yet keep it clean and manageable.
I need the common code to manage the findViewById, setOnClickListener and onClick method. As a example, both activities take start and end locations in gps. Both activity's have a time/date dialog button.
Some thoughts
- So GetGPSAndTimeActivity where I do all the findViewById, onClickListener, onCreateDialog. Then should I extend from GetGPSAndTimeActivity ?
- Use Fragments like Fragment in Android 2.3.3 and lesser
I prefer option 1.