启动相同的活动在android的按钮 [英] starting the same activity with button in android

查看:96
本文介绍了启动相同的活动在android的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能开始同一个活动上按一下按钮。 我在我的MainActivity一个按钮,我想,当我点击该按钮当前活动(MainActivity)重新启动(重新开始)?在此先感谢。

Is it possible to start the same activity on button click. I have a button in my MainActivity and I want that when I click that button the current Activity (MainActivity) restarts (start again) ? Thanks in Advance.

推荐答案

试试这个:)

Button buttonOne = (Button) findViewById(R.id.button1);
buttonOne.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
       Intent intent = new Intent(MainActivity.this,
                        MainActivity.class);

                startActivity(intent);
}
 });

但我不明白为什么你要做到这一点:P

But i dont understand why you wanna do this :P

这篇关于启动相同的活动在android的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆