Android - Calling a method in one activity from another, without starting new activity

后端 未结 4 1918
北荒
北荒 2020-12-19 20:47

I\'m developing an Android app using GreenDroid. The application is just for testing atm, so it all it contains is an ActionBar with a refresh button, three tabs, and an act

4条回答
  •  感情败类
    2020-12-19 21:39

    Right. If the method is static, which it probably should be if this is your goal, just call it like this:

    YourClass.staticMethod(params);
    

    If not, you'll need to create an object for it.

    YourClass yourClass = new YourClass(constructorParams);
    yourClass.method(params);
    

    That should do it.

提交回复
热议问题