views:

30

answers:

1

I split my inner View class from my Main class into its own file. In my main class, I have the view set as an onTouchListener which records user movement into a matrix so it can translate and scale the view. After separating it everything works but im unsure how to pass the matrix to the View for onDraw to update. Any suggestions? Thanks

A: 

I can think of two ways to do this:

You could create a variable for your matrix in your View class and a method that accepts a matrix as argument and that updates the var with this matrix value. Then you can call this method from your main Activity before calling your onDraw() method, which can then use this internal var for its calculations and so on.

An alternative would be for your matrix var in your main class to be static so you can call it from your View without needing to have an instance of your main class accessible within your View class.

The latter method is the best as it doesn't require your app to maintain two vars with essentially the same value but the former method might be easier to implement, depending on how your matrix is calculated/implemented.

FreewheelNat