Diverting thoughts of wanting to gamble by doing something else is one thing that can be done to avoid the habit of gambling, but this is not easy because for people who cannot control themselves they will still follow their desire to gamble and for those who are addicted no matter how difficult the situation is they will follow their desire to gamble.
Diverting your thoughts to something different from gambling is not a permanent solution but only a short term solution that you might not be capable of doing someday when the desperate to gamble increase more. What you should be capable of doing is to not gamble at all regardless of not doing anything else. Learn to say no to gambling and train your body to not allow it get to a stage that when ever you see gambling activities going on, you want to participate too. Prevention of addiction can be done by controlling how you gamble for people that are already into gambling. Controlling your gambling schedules will help reduce how long you gamble and how much that you are losing and this can help prevent gambling addiction too.
If making money and taking gambling as a source of income is the reason why one is addicted to gambling, then diverting to other things that can yield money and takes one time can complete make one not to have o much interest in gambling because the main aim for gambling something else is giving you what you want which is money.
But their is nothing as powerful as discipline when it comes to gambling, discipline will enable one to make any decision and stick by it. Without discipline you will always go back to the former style of gambling but with discipline and diverting into others things it is possible to completely free from gambling addiction.