Wednesday, March 4, 2009

Technical Key Points of Androidmine Project

Here are the techincal key points I learned from the open source project, androidmine.
Its current version is 0.7.

1. Customize the activity theme (window without title)
AndroidManifest.xml
<activity android:name=".Main" android:theme="@style/Theme.Game">
...
res/values/styles.xml
<style name="Theme.Game">
<item name="android:windowNoTitle">true</item>
</style>

2. Set the conent view for the activity
Use android.app.Activity.setContentView(View view) to set the activity content to an explicit view. This view is placed directly into the activity's view hierarchy. It can itself be a complex view hierarhcy. By this way, you can switch any view you want to show.
Overwrite onLayout, onDraw to customize the view
Overwrite onKeyUp, onKeyDown and onTouchEvent to handle the user input
Call invalidate in the UI thread, or postInvalidate in the non-UI thread to make the onDraw called

3. Use android.os.Handler to send and handle messages, schedule an action in the feature

4. Use android.media.MediaPlayer to play background music in a separated thread

No comments:

Post a Comment