How to start new activity on button click

后端 未结 24 1610
傲寒
傲寒 2020-11-21 05:54

In an Android application, how do you start a new activity (GUI) when a button in another activity is clicked, and how do you pass data between these two activities?

24条回答
  •  野的像风
    2020-11-21 06:40

    Start another activity from this activity and u can pass parameters via Bundle Object also.

    Intent intent = new Intent(getBaseContext(), YourActivity.class);
    intent.putExtra("USER_NAME", "xyz@gmail.com");
    startActivity(intent);
    

    Retrive data in another activity (YourActivity)

    String s = getIntent().getStringExtra("USER_NAME");
    

提交回复
热议问题