Why does Claudius' attitude towards Hamlet change over the course of the play.
Concerning Shakespeare's Hamlet, Claudius specifically changes his behavior toward Hamlet once he realizes Hamlet knows the details of his treachery. After the play-within-the-play makes Claudius aware that Hamlet knows Claudius killed King Hamlet, he acts directly against Hamlet by sending him to England and ordering his execution.
What you see as a change in attitude, however, is probably more of just a drop in the act Claudius puts on. Claudius "plays" or wears a mask or performs a role, as virtually all the characters in the play do. Claudius's role when it comes to Hamlet is to convince Gertrude that he's doing everything he can to make Hamlet happy, and to get Hamlet to accept him. After the play is performed in Act 3, while Claudius still "acts nice" in front of Gertrude, he drops the act when Gertrude isn't present--winning Hamlet's approval is no longer an issue. Eliminating Hamlet becomes the issue.
Claudius is wary of Hamlet and knows Hamlet is dangerous from the opening moments of the play. He tries to keep Hamlet in Elsinor, rather than allow him to go back to school, in order, presumably, to keep watch over him and keep him under control. Claudius only "seems" to be friendly and kindly toward Hamlet. Hamlet may not be acting when he seems upset about his father's death, but Claudius is acting when he appears to have Hamlet's best interests in mind.
Thus, what you see concerning Claudius's change in attitude toward Hamlet is probably more the difference between Claudius's public and private treatement of Hamlet, and the diffeence between before the play-within-the-play and after. His attitude toward Hamlet probably remains the same throughout. He just masks it most of the time.
Claudius has a very good reason for his change in attitude toward Hamlet through the course of the play. Hamlet has discovered that Claudius has murdered his father and married his mother. Claudius is Hamlet's uncle; he thinks that he has gotten away with his crime. He now has control of the throne, which would have been Hamlet's by right of succession. Hamlet is not so concerned about the throne as he is about his mother's part in the conspiracy (if there is one) and the fact that Claudius' ambition has caused him to commit fratricide. Hamlet decides to catch Claudius and kill him, so he begins to act crazy in order to un-nerve everyone. He thoroughly succeeds, to the point that his girlfriend Ophelia apparently drowns herself, and Claudius becomes very wary of Hamlet. He's not just the bumbling nephew who can be counted on to not make waves, as Claudius thought he was. Claudius' guilt comes out whenever he sees Hamlet; he knows that his days are numbered and that Hamlet knows his crimes.