老师啊,我的代码调试的时候,播放第一次正常,播放第二次的时候,那个按钮就出不来了!
五更寒
2014-08-15
5 回答
package com.tingno.guessmusic.ui; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.animation.Animation; import android.view.animation.Animation.AnimationListener; import android.view.animation.AnimationUtils; import android.view.animation.LinearInterpolator; import android.widget.ImageButton; import android.widget.ImageView; import com.tingno.guessmusic.R; public class MainActivity extends Activity { //唱片相关动画 private Animation mPanAnim; private LinearInterpolator mPanLin; //拨杆相关动画声明 private Animation mBarInAnim; private LinearInterpolator mBarInLin; private Animation mBarOutAnim; private LinearInterpolator mBarOutLin; private ImageView mViewPan; private ImageView mViewPanBar; //Play 案件事件 private ImageButton mBtnPlayButtonStart; private boolean mIsRunning = false; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mViewPan = (ImageView) findViewById(R.id.imageView1); mViewPanBar = (ImageView) findViewById(R.id.imageView2); //初始化动画 mPanAnim = AnimationUtils.loadAnimation(this, R.anim.rotate); mPanLin = new LinearInterpolator(); mPanAnim.setInterpolator(mPanLin); mPanAnim.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { mViewPanBar.setAnimation(mBarOutAnim); } }); mBarInAnim = AnimationUtils.loadAnimation(this, R.anim.rotate_45); mBarInLin = new LinearInterpolator(); mBarInAnim.setFillAfter(true); mBarInAnim.setInterpolator(mBarInLin); mBarInAnim.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { mViewPan.startAnimation(mPanAnim); } }); mBarOutAnim = AnimationUtils.loadAnimation(this, R.anim.rotate_d_45); mBarOutLin = new LinearInterpolator(); mBarOutAnim.setFillAfter(true); mBarOutAnim.setInterpolator(mBarOutLin); mBarOutAnim.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { //整套动画播放完毕 mIsRunning=false; mBtnPlayButtonStart.setVisibility(View.VISIBLE); } }); mBtnPlayButtonStart =(ImageButton) findViewById(R.id.btn_play_start); mBtnPlayButtonStart.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub handlePalyButton(); } }); } //处理圆盘中间的播放按钮,开始播放音乐 private void handlePalyButton(){ if(mViewPanBar != null){ if(!mIsRunning){ mIsRunning=true; //开始拨杆进入动画 mViewPanBar.startAnimation(mBarInAnim); mBtnPlayButtonStart.setVisibility(View.INVISIBLE); } } } @Override public void onPause(){ mViewPan.clearAnimation(); super.onPause(); } }
这个是java部分。不知道有什么写的不对。
另外还有个问题就是,图片资源之前是乱切的,后来看到老师有资源然后就下载下来换了。
调试了几遍,实际显示效果都没换。是不是要什么刷新之类的操作还是怎么样?
举报
0/150
提交
取消