gpt4 book ai didi

android - 录音时播放动画

转载 作者:行者123 更新时间:2023-11-30 03:11:29 25 4
gpt4 key购买 nike

我正在开发虚拟香烟,我在其中使用图像和帧动画我想在录制音频时播放动画...任何人都可以提供有关此应用程序的想法吗?

我的代码在下面

public class MainActivity extends Activity {
ImageView imageView;
AnimationDrawable animation;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView=(ImageView)findViewById(R.id.imageView1);
imageView.setBackgroundResource(R.drawable.myanim);
animation=(AnimationDrawable)imageView.getBackground();
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
// TODO Auto-generated method stub
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
animation.start();
}
else {
animation.stop();
}
}

最佳答案

public class MainActivity extends Activity {
ImageView imageView;
Button record,stop;
AnimationDrawable animation;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

imageView=(ImageView)findViewById(R.id.imageView1);
record =(Button)findViewById(R.id.record);
stop =(Button)findViewById(R.id.stop);
imageView.setBackgroundResource(R.drawable.myanim);
animation=(AnimationDrawable)imageView.getBackground();

record.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//do your function of record
animation.start();
}}

stop.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//do your function of record
animation.stop();
}}

}


}

关于android - 录音时播放动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20878165/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com