How could David bathe, anoint and change his clothes? These are forbidden to an Avel!
Radak #1: This was before the burial. Aveilus starts only after burial. He did these in order to go to Beis Hashem to bow and thank for the bad. One must bless for bad and thank Hashem and accept it b'Simchah, just like for the good - "Chesed u'Mishpat Ashirah" (Tehilim 101:1) - I will sing whether [I receive] Chesed or Mishpat. "Kos Yeshu'os Esa uv'Shem Hashem Ekra
Radak: Do not answer that he bathed, anointed and changed his clothes at night, for Torah Aveilus is only during the day. The verse says that he rose from the ground and [immediately] bathed, anointed and changed his clothes!
Radak (at the end of this Dibur): It seems that David had Bi'ah with her only that one time in Uriyah's lifetime. (If so, why would David be unsure? Perhaps here Radak explains unlike he says below. Or perhaps she erred; really, she became pregnant only after he married her after Uriyah died (refer to 11:6:3:1). Or, conception can be up to three days after Bi'ah; due to this, he was unsure whether or not birth was in the eighth month. Or sometimes a baby develops like a seven or eight month baby, but delays a month before coming out! - PF)
Radak: If so, how do we expound (Mo'ed Katan 15b) that Bi'ah is forbidden during Aveilus from verse 24 (he had Bi'ah with Bas Sheva)? It is a mere support (Asmachta). There was a tradition for the law. The same day he consoled his wife, lest she be pained and cry over the baby.