From my layman understanding there are certain hormonal compound markers that can flick genes on or off during fetal development. These markers can be passed down or stacked thus increasing or decreasing sensitivity to testosterone. I forget what journal I was reading so unfortunately I don't have a source for you. But I agree with OAA that it's a combination of genetic and environmental factors, with the environment most likely playing a much, much smaller role. The fact that homosexuality also occurs in nature should be a good indication that homosexuality isn't a "learned" behavior like many conservative Christians would lead us to believe.