Solomon had 700 wives and 300 concubines but even if he only had one strange wife these things could still have transpired.
1 Kings 11:2-4 KJV
 Of the nations concerning which the Lord said unto the children of Israel, Ye shall not go in to them, neither shall they come in unto you: for surely they will turn away your heart after their gods: Solomon clave unto these in love.  And he had seven hundred wives, princesses, and three hundred concubines: and his wives turned away his heart.  For it came to pass, when Solomon was old, that his wives turned away his heart after other gods: and his heart was not perfect with the Lord his God, as was the heart of David his father.