How to start new activity on button click

后端 未结 24 1713
傲寒
傲寒 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:45

    Take Button in xml first.

      

    Make listner of button.

     pre.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActivity.this, SecondActivity.class);
                startActivity(intent);
            }
        });
    

提交回复
热议问题