Narrated `Abdullah:

We used to greet the Prophet pbuh while he was praying and he used to answer our greetings.
When we returned from An-Najashi (the ruler of Ethiopia), we greeted him, but he did not answer us (during the prayer) and (after finishing the prayer) he said, “In the prayer one is occupied (with a more serious matter).”

Reference : Sahih al-Bukhari 1199
In-book reference : Book 21, Hadith 2
USC-MSA web (English) reference : Vol. 2, Book 22, Hadith 290