How to navigate from one screen to another screen

前端 未结 16 1492
失恋的感觉
失恋的感觉 2020-11-29 04:31

How to navigate from one Activity screen to another Activity screen? In the first screen I\'m having one button if I click the button it has to move to another Activity scre

16条回答
  •  佛祖请我去吃肉
    2020-11-29 04:54

    Just go to XML file and add Onclick = "opennewactivity" in button xml.

    Then go to java code and create class opennewactivity you can just make it my clciking alt+Enter in xml code's "opennewactivity". in that just write

    Intent intent = new Intent(this, newacivity.class);
    startActivity(intent);
    

    and if you want user to not get back to first activity again then just write this

    Intent intent = new Intent(this, newactivity.class);
    startActivity(intent);
    finish();
    

提交回复
热议问题