Leg muscle cramps can happen because of nutrient deficiencies
There are a few different electrolytes that, if deficient, can lead to leg muscle cramps. They are; sodium, potassium, calcium and magnesium. I suggest drinking a sports drink hight in electrolytes before any kind of physical activity. This is a great way to prevent muscle cramps.
Stretching can reduce the chance of leg muscle cramps
Obviously you need to do some stretching before any physical activity. Get those muscles moving and completely loosened up. This is an important way to prevent leg muscle cramps.
Drink plenty of water before any muscular activity. Remember, by the time you feel thirsty you are already dehydrated and highly succeptable to cramps. Drink water to prevent muscle cramps.
This is more common in older people, but it applies to everyone to some degree. Don't wear tight, restrictive clothing before physical activity as this can contribute to the onset of leg muscle cramps.
So, to summarize..
Drink water, take in some electrolytes and do some good stretching before any physical activity. Do these things and you'll greatly reduce the chance of getting one of those painful cramps.