0
I have a method in Mainactivity2:
public void addfoto(View view) {
// meu código bla bla bla bla
}
And I want to call this method on Mainactivity. I’m trying this way but it gets the code wrong:
MainActivity2 m2 = new MainActivity2();
m2.addfoto();
But it’s not working. How I do ?
What is the error that appears? Or no error appears? Do not omit anything, any detail is important to get a proper response
– Samuel Fontebasso
You have to matter the class Mainactivity2 if not, it will not work. Any doubt is just read this reply.
– NoobSaibot
That’s stupid. It was the import of the class just like the colleague above spoke. Thank you !!!!
– Luciana Freire Efelipe Correia
What if to call Onclicklistner another class? how do I ?
– Luciana Freire Efelipe Correia
This is not a good principle, it is better to put the code of that click in a class that both Activities can call, assuming that it is indeed the same
– Isac