Acceptance
You need to accept that the relationship with your ex is over. Sure, it is easier said than done, but deluding yourself isn't working either. Accept that you are worthy of being loved and the relationship with your ex wasn't meant to be. Accepting a breakup that was not meant to be will enable you to accept a relationship in the future that is meant to be. Focusing on a future relationship will redirect your focus from your ex.
Analyze
Even though the point is to stop focusing on your ex, take a little time to analyze the dynamics of the relationship when you were together. What were the problems? Were there communication issues? Were there conflicting beliefs or interests? What led to the breakdown of your relationship? By analyzing these aspects, you can better prepare yourself for a future relationship. If you had trouble communicating, learn to open yourself up more to people in everyday life. If you had anger issues that damaged your relationship, get them under control before bringing a new person into your life. The thoughts of how to improve yourself for a future relationship will take your mind off of your ex.
Support
After a breakup you need a support network of good friends or family. Talking to friends or family about what you are feeling and going through will help you to heal. But, your support network should also be a source of joy and a way to focus on other people and take your focus off of your ex. Reach out to those in your support network. They have problems, too. Surround yourself with those who care and don't isolate yourself where you are alone with continuous thoughts of your ex.
Stay Active
After a breakup, it is hard to focus on yourself with all those haunting thoughts of your ex. Staying active in body can help to lessen the damaging, emotional thoughts and the focus on your ex. Go to the gym or work out in your own home with a friend. Swimming is great exercise and even if you don't have your own pool, you can go to the YMCA for little cost. Take a daily walk in your neighborhood or join a sports team. Anything that revs up your body will turn your focus off of your ex and to a more positive direction.