Call a public method in the Activity class from another class?

前端 未结 8 2354
无人及你
无人及你 2020-12-05 19:33

MAIN ACTIVITY

    public class MyActivity() extends Activity
    {
        onCreate()
        {
            MyClass myobj=new MyClass();    
        }
               


        
8条回答
  •  我在风中等你
    2020-12-05 19:59

    Make that method as static so you can call without creating the class object

    public static void Mymethod()
    {}
    

    and call like this way

    MainActivity.Mymethod();
    

提交回复
热议问题