![](/img/trans.png)
[英]How to I launch an activity with an Intent and pass a variable in the new activity?
[英]How To Stop FrameAnimation And launch a new Activity ??(Intent)
public class Mainpage extends Activity {
// Declaring an Image View and an Animation Drawable
ImageView view;
ImageView view1;
AnimationDrawable frameAnimation;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mainpage);
// Typecasting the Image View
view = (ImageView) findViewById(R.id.imageAnimation);
// Setting animation_list.xml as the background of the image view
view.setBackgroundResource(R.drawable.animation_list);
// Typecasting the Animation Drawable
frameAnimation = (AnimationDrawable) view.getBackground();
}
// Called when Activity becomes visible or invisible to the user
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
// Starting the animation when in Focus
frameAnimation.start();
} else {
// Stoping the animation when not in Focus
frameAnimation.stop();
}
}
}
之后有什么方法可以停止帧动画并启动活动/意图吗?
我试图在谷歌上搜索此查询,但是大多数代码包含“开始”和“停止”按钮以停止帧动画...需要一个没有按钮的查询..帮助!
是的frameAnimation.stop();
方法用于停止动画。 对于启动新的Activity
您可以使用以下代码-
startActivity(Mainpage.this, newActivity.class);
要么
Intent i = new Intent(this, newActivity.class);
startActivity(i);
您可以使用要启动的Activity
名称代替newActivity
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.