"In Acts 13.22 God says David was a man after mine own heart. If my memory serves me correctly, David was both an adulterer and a murderer. How can God make this claim?"
Actually, that claim is made both in the Old and the New Testaments--1 Kings 9.4; 11.4; and 14.8 all claim David as a man who followed the precepts of God closely. And indeed in 2 Samuel 11, David had an adulterous affair with Bathsheba and when she conceived David called for the murder of her husband. Surely, David doesn't come across as a very righteous person, at least by today's standards. So how does he get such high billing when other kings are compared to him?
There are at least two possible answers to the dilemma. The first is somewhat simplistic, and yet it is a lesson for us today. It is clear that, according to the varied accounts of his reign, David was quite human. He was tempted by the sight of an attractive woman and he gave into his temptations. He evaded responsibility for his actions after Bathsheba became pregnant, and in his frustration he had her husband killed. Later in his life he would make other blunders that are recorded for posterity. But no matter what the mistakes, the sins, or the evil deeds, when David is confronted with his wrongs he repents and returns to God. Perhaps his tenacity is why God can call David "one after my own heart."
Perhaps there's hope for us too.
However, there is another, more academic, reason why David may have been given this appellation by the Biblical writers. To understand this reason we have to examine a brief history of the sacrificial system. Up until the construction of the temple in Jerusalem by King Solomon, the nation of Israel made their sacrifices at a number of sanctuaries. Indeed, by David's reign there seems to have been sanctuaries in nearly every Israelite town. The Levites, the family lineage of the priesthood, staffed these sanctuaries nationwide. However, when the Temple was built there was a move to centralize worship and the sacrificial system to the capital city. Over time many of the sanctuaries were closed as the priesthood relocated to Jerusalem.
As time passed sacrifices made outside of Jerusalem became less tolerated by the powerful priesthood. Eventually the priesthood tried to influence the kings to ban worship beyond the capital city. Some kings, Hezekiah and Josiah, were quite zealous and tore down whole sanctuaries, also known as "high places" (1 Kings 3.2), and put to death those priests who worshiped at the traditional sanctuaries. However, virtually every other king allowed the continued use of the sanctuaries, contrary to the desires of the priesthood. When the later priesthood recorded the sacred histories of Israel in the books of Kings and Chronicles, king after king was described as "walking in the ways of God" but "they did not tear down the high places." The priesthood declared that any who had sacrificed or allowed sacrifices at these high places were idol worshipers (2 Kings 23.5)--even if all the other acts the kings did were considered righteous (cf. 1 Kings 15.14).
And what of David? David was not connected to any of the high places during his reign--indeed the only sacrifices he was connected with as king were made in Jerusalem or its immediate environs. Thus David was never considered to be an idolater by the priesthood. Thus, according to scripture, his heart never betrayed the one true God and he could be considered a man "after God's own heart," regardless of his other acts.
Although David was a profane man in many respects, despite his shortcomings and sins he always returned to God. Further, because he had no association with the "high places" he was given the favorable appellation by the priesthood and the chroniclers of history as one after God's own heart.