Ditto Daniel and Vanessa,
Also another variation is he may be gay himself. Some closeted types will throw out a negative to test the waters in which you swim to see if they would be safe for them to disclose themselves. As you experience first hand, being gay has it's moments of insecurity. You might try asking him some further questions to see where he really stands before being vulnerable to him.
You are the world Krishnamurti