简体   繁体   中英

How can I change my android activity on button click? - Stack Overflow

I am new to programming and don't know how to jump from one activity to another activity.

The first Activity name is Splash and the Second one name is Home.

I am trying to jump from Splash to Home.

Can Anybody help me to do so?

Suppose your button in splash activity and you want to redirect main activity on button click you can write code like below.

Button button = findViewById(R.id.button);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(SplashActivity.this,HomeActivity.class);
            startActivity(intent);
        }
    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM