First of all, note that all integers are either 0,1, or 2 modulo 3 (if you're not familiar with this terminology, it means that every integer is either a multiple of 3, or it is 1 or 2 away from a multiple of 3).
So, we can think of our numbers as
![\begin{array}{c|c}x&x\mod 3\\0&0\\1&1\\2&2\\3&0\\4&1\\5&2\\6&0\\7&1\\8&2\\9&0\end{array}](https://tex.z-dn.net/?f=%5Cbegin%7Barray%7D%7Bc%7Cc%7Dx%26x%5Cmod%203%5C%5C0%260%5C%5C1%261%5C%5C2%262%5C%5C3%260%5C%5C4%261%5C%5C5%262%5C%5C6%260%5C%5C7%261%5C%5C8%262%5C%5C9%260%5Cend%7Barray%7D)
In order to make sure that the sum of any three adjacent numbers is divisible by 3, we have to make sure that any group of 3 three adjacent numbers contains a 0, a 1 and a 2. This is possible only if we arrange our 9 numbers in 3 groups of 3 numbers containing 0,1 and 2 exactly once, repeating always the same pattern.
For example, we could arrange our numbers following the pattern
![0,1,2,0,1,2,0,1,2](https://tex.z-dn.net/?f=0%2C1%2C2%2C0%2C1%2C2%2C0%2C1%2C2)
or
![2,0,1,2,0,1,2,0,1](https://tex.z-dn.net/?f=2%2C0%2C1%2C2%2C0%2C1%2C2%2C0%2C1)
We have
possible patterns. Suppose for example that we choose the pattern
![0,1,2,0,1,2,0,1,2](https://tex.z-dn.net/?f=0%2C1%2C2%2C0%2C1%2C2%2C0%2C1%2C2)
One possible way of following this pattern would be the arrangement
![3,1,2,6,4,5,9,7,8](https://tex.z-dn.net/?f=3%2C1%2C2%2C6%2C4%2C5%2C9%2C7%2C8)
In fact, we substituted every '0' with a multiple of 3 (3, 6 or 9), every '1' with a number 1 away from a multiple of 3 (1, 4 or 7) and every '2' with a number 2 away from a multiple of 3 (2, 5 or 8).
This means that, once we fix a patter, we have 3 choices for the first 3 slots, 2 choices for the next 3 slots, and the final slot will be fixed. So, we have
![3\cdot 3\cdot 3\cdot 2 \cdot 2 \cdot 2 = 216](https://tex.z-dn.net/?f=3%5Ccdot%203%5Ccdot%203%5Ccdot%202%20%5Ccdot%202%20%5Ccdot%202%20%3D%20216)
possible ways of following a fixed pattern. Since the number of patterns was 6, we have
![216\cdot 6 = 1296](https://tex.z-dn.net/?f=216%5Ccdot%206%20%3D%201296)
possible arrangements.