How do we call a method located in another activity? For example I'm trying to use
Fantastic news! We've Found the answer you've been seeking!
Question:
How do we call a method located in another activity?
For example I'm trying to use this method from the "MainActivity"
public void change () {
ConstraintLayout layout = findViewById(R.id.main_layout);
layout.setBackgroundResource(R.drawable.wallpaper);
}
into the second activity (SecondActivity) when clicking a button
I tried this
MainAcitvity MA = new MainActivity();
MA.change();
but it didn't work. what's the correct way to do it in Android?
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date: