During the 20 years it takes Solomon to build the Temple and his own palace (guess it wasn't as quick as it seemed), Solomon has a lot of other stuff on his plate, too. He's swamped.
He rebuilds some cities and attacks some others. He starts all kinds of important infrastructure projects, too. Basically, whatever he needs or wants to do for Israel, he does.
When he conquers a city, he takes foreigners as slaves. But no citizen of Israel is ever the King's slave. During this time, Solomon decides to marry the Egyptian Pharaoh's daughter. She doesn't have a name, but biblical ladies are used to that.
Even though this princess is obviously important, Solomon can't have her staying in the royal palace. After all, it's a holy place. The Ark of the Covenant was there when David was king. She gets her own house so she doesn't taint all the sacred stuff with her foreign ways.
Meanwhile, Solomon continues being faithful to God. He offers sacrifices to God just like Moses would have wanted. And he appoints priests and temple-workers, just like David would have done.
When the Temple is finally done, Solomon can kick back and relax. Well, not quite.