Start another activity by clicking a button

无人久伴 提交于 2019-12-03 07:34:42

You need to call another activity like this inside the OnClickListener() of button

Button mondayEdit= (Button)findViewById(R.id.button1);
    mondayEdit.setOnClickListener(new OnClickListener() 
    {   public void onClick(View v) 
        {   
            Intent intent = new Intent(main.this, secondActivity.class);
                startActivity(intent);      
                finish();
        }
    });

Probably your code is showing error due to Android manifest file, Try adding proper class in manifest file. Making first activity as main , and other as default.Others part of code is exactly fine.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!