How to call a class method CCColorLayer from another method (it expands activity), Android?

I need to call a class A method (it extends CCColorLayer) from a class B method (it extends activity). How is this possible? Tried to create an object for class A in class B. But this is not a solution. Each time you create a different layer. please, help.

Thanks in advance.

+5
source share
1 answer

Do you want to create a singleton template?

 public Class A extends CCcolorlayer
    { 
    private static final A INSTANCE= new A();
     A() 
    { 
    }
     public static A getInstance() 
    { return INSTANCE; 
    } 

    }

From class B

 public class B
{
   B()
     {
        A.getInstance();// which returns object of the class A.(you dont need to create object of class A everytime.)
     }

}

I'm not sure what you are looking for.

0
source

All Articles