package com.javacc.android.piano;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageButton;
import android.widget.Toast;
import android.widget.Button;
import android.view.View;
import android.view.MotionEvent;
import android.media.MediaPlayer;
import java.io.IOException;
/**
* @author: ZhangFL
*/
public class Piano extends Activity {
private ImageButton imageButton_white1;
private ImageButton imageButton_white2;
private ImageButton imageButton_white3;
private ImageButton imageButton_white4;
private ImageButton imageButton_white5;
private ImageButton imageButton_white6;
private ImageButton imageButton_white7;
private ImageButton imageButton_white8;
private ImageButton imageButton_black1;
private ImageButton imageButton_black2;
private ImageButton imageButton_black3;
private ImageButton imageButton_black4;
private ImageButton imageButton_black5;
private MediaPlayer mediaPlayer01;
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.main);
mediaPlayer01 = new MediaPlayer();
// mediaPlayer01 = MediaPlayer.create(Piano.this, R.raw.white1);
imageButton_white1 = (ImageButton) findViewById(R.id.white1);
imageButton_white2 = (ImageButton) findViewById(R.id.white2);
imageButton_white3 = (ImageButton) findViewById(R.id.white3);
imageButton_white4 = (ImageButton) findViewById(R.id.white4);
imageButton_white5 = (ImageButton) findViewById(R.id.white5);
imageButton_white6 = (ImageButton) findViewById(R.id.white6);
imageButton_white7 = (ImageButton) findViewById(R.id.white7);
imageButton_white8 = (ImageButton) findViewById(R.id.white8);
imageButton_black1 = (ImageButton) findViewById(R.id.black1);
imageButton_black2 = (ImageButton) findViewById(R.id.black2);
imageButton_black3 = (ImageButton) findViewById(R.id.black3);
imageButton_black4 = (ImageButton) findViewById(R.id.black4);
imageButton_black5 = (ImageButton) findViewById(R.id.black5);
imageButton_white1.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
play(R.raw.white1);
imageButton_white1.setImageResource(R.drawable.whiteback1);
}
if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
imageButton_white1.setImageResource(R.drawable.white1);
}
return false;
}
});
imageButton_white2.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
play(R.raw.white2);
imageButton_white2.setImageResource(R.drawable.whiteback2);
}
if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
imageButton_white2.setImageResource(R.drawable.white2);
}
return false;
}
});
//
imageButton_white3.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
play(R.raw.white3);
imageButton_white3.setImageResource(R.drawable.whiteback3);
}
if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
imageButton_white3.setImageResource(R.drawable.white3);
}
return false;
}
});
imageButton_white4.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
play(R.raw.white4);
imageButton_white4.setImageResource(R.drawable.whiteback4);
}
if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
imageButton_white4.setImageResource(R.drawable.white4);
}
return false;
}
});
imageButton_white5.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
play(R.raw.white5);
imageButton_white5.setImageResource(R.drawable.whiteback5);
}
if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
imageButton_white5.setImageResource(R.drawable.white5);
}
return false;
}
});
imageButton_white6.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
play(R.raw.white6);
imageButton_white6.setImageResource(R.drawable.whiteback6);
}
if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
imageButton_white6.setImageResource(R.drawable.white6);
}
return false;
}
});
imageButton_white7.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
play(R.raw.white7);
imageButton_white7.setImageResource(R.drawable.whiteback7);
}
if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
imageButton_white7.setImageResource(R.drawable.white7);
}
return false;
}
});
imageButton_white8.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
play(R.raw.white8);
imageButton_white8.setImageResource(R.drawable.whiteback8);
}
if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
imageButton_white8.setImageResource(R.drawable.white8);
}
return false;
}
});
imageButton_black1.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
play(R.raw.black1);
}
if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
imageButton_black1.setImageResource(R.drawable.black1);
}
return false;
}
});
imageButton_black2.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
play(R.raw.black2);
}
if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
imageButton_black2.setImageResource(R.drawable.black2);
}
return false;
}
没有合适的资源?快使用搜索试试~ 我知道了~
小程序 小钢琴源码.rar
共143个文件
png:59个
class:47个
ogg:13个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 190 浏览量
2023-02-03
11:51:13
上传
评论
收藏 4.22MB RAR 举报
温馨提示
免责声明:资料部分来源于合法的互联网渠道收集和整理,部分自己学习积累成果,供大家学习参考与交流。收取的费用仅用于收集和整理资料耗费时间的酬劳。 本人尊重原创作者或出版方,资料版权归原作者或出版方所有,本人不对所涉及的版权问题或内容负法律责任。如有侵权,请举报或通知本人删除。
资源推荐
资源详情
资源评论
收起资源包目录
小程序 小钢琴源码.rar (143个子文件)
resources.ap_ 562KB
resources.ap_ 562KB
com.javacc.android.piano.Piano.apk 570KB
com.javacc.android.piano.Piano.apk 570KB
MyPiano.apk 570KB
Piano.class 5KB
Piano.class 5KB
R$drawable.class 1KB
R$drawable.class 1KB
Piano$15.class 1KB
Piano$15.class 1KB
Piano$14.class 1KB
Piano$4.class 1KB
Piano$5.class 1KB
Piano$8.class 1KB
Piano$2.class 1KB
Piano$6.class 1KB
Piano$1.class 1KB
Piano$3.class 1KB
Piano$7.class 1KB
Piano$14.class 1KB
Piano$13.class 1KB
Piano$10.class 1KB
Piano$11.class 1KB
Piano$12.class 1KB
Piano$9.class 1KB
Piano$5.class 1KB
Piano$4.class 1KB
Piano$2.class 1KB
Piano$8.class 1KB
Piano$6.class 1KB
Piano$7.class 1KB
Piano$1.class 1KB
Piano$3.class 1KB
Piano$10.class 1KB
Piano$13.class 1KB
Piano$11.class 1KB
Piano$12.class 1KB
Piano$9.class 1KB
R$id.class 788B
R$id.class 788B
R$raw.class 765B
R$raw.class 765B
R.class 627B
R.class 623B
R$string.class 416B
R$string.class 416B
R$layout.class 412B
R$layout.class 412B
R$attr.class 358B
R$attr.class 358B
BuildConfig.class 357B
.classpath 364B
classes.dex 12KB
classes.dex 11KB
classes.dex 11KB
MyPiano.iml 1KB
MyPiano.ipr 18KB
MyPiano.iws 28KB
Piano.java 11KB
R.java 4KB
BuildConfig.java 166B
white7.ogg 9KB
black1.ogg 8KB
white3.ogg 8KB
black4.ogg 7KB
black5.ogg 7KB
white8.ogg 7KB
white5.ogg 7KB
white1.ogg 7KB
black3.ogg 6KB
white2.ogg 6KB
black2.ogg 6KB
white4.ogg 6KB
white6.ogg 6KB
background.png 176KB
background.png 176KB
1-1209161506100-L.png 107KB
white6.png 22KB
white6.png 22KB
white7.png 22KB
white7.png 22KB
white3.png 22KB
white3.png 22KB
white5.png 22KB
white5.png 22KB
white2.png 22KB
white2.png 22KB
white4.png 22KB
white4.png 22KB
white1.png 21KB
white1.png 21KB
white8.png 19KB
white8.png 19KB
black2.png 9KB
black2.png 9KB
black4.png 9KB
black4.png 9KB
black1.png 9KB
black1.png 9KB
共 143 条
- 1
- 2
资源评论
大富大贵7
- 粉丝: 390
- 资源: 8868
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功