初学Android开发!求一个完整的详细的Android小程序源码参考!
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了初学Android开发!求一个完整的详细的Android小程序源码参考!相关的知识,希望对你有一定的参考价值。
参考技术A 媒体播放器源码Audio.javapackage org.example.audio;
import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.KeyEvent;
public class Audio extends Activity
private MediaPlayer up, down, left, right, enter;
private MediaPlayer a, s, d, f;
@Override
public void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Native rate is 44.1kHz 16 bit stereo, but
// to save space we just use MPEG-3 22kHz mono
up = MediaPlayer.create(this, R.raw.up);
down = MediaPlayer.create(this, R.raw.down);
left = MediaPlayer.create(this, R.raw.left);
right = MediaPlayer.create(this, R.raw.right);
enter = MediaPlayer.create(this, R.raw.enter);
a = MediaPlayer.create(this, R.raw.a);
s = MediaPlayer.create(this, R.raw.s);
d = MediaPlayer.create(this, R.raw.d);
f = MediaPlayer.create(this, R.raw.f);
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
MediaPlayer mp;
switch (keyCode)
case KeyEvent.KEYCODE_DPAD_UP:
mp = up;
break;
case KeyEvent.KEYCODE_DPAD_DOWN:
mp = down;
break;
case KeyEvent.KEYCODE_DPAD_LEFT:
mp = left;
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
mp = right;
break;
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_ENTER:
mp = enter;
break;
case KeyEvent.KEYCODE_A:
mp = a;
break;
case KeyEvent.KEYCODE_S:
mp = s;
break;
case KeyEvent.KEYCODE_D:
mp = d;
break;
case KeyEvent.KEYCODE_F:
mp = f;
break;
default:
return super.onKeyDown(keyCode, event);
mp.seekTo(0);
mp.start();
return true;
以上是关于初学Android开发!求一个完整的详细的Android小程序源码参考!的主要内容,如果未能解决你的问题,请参考以下文章
求助 给个modbus rtu协议的完整代码 最好附有详细解释 初学者 谢
android开发过程中怎样通过代码设置系统时间,求详细解答。从第一步到实现????
安卓开发:如何静态和动态设置textView的文本和背景色彩,如何填?初学不知填什么.要详细