Rasulullah (sallallahu alayhi wasallam) said: "Verily, even a little riya is shirk."
Riya (show) is to display ibaadat (worship) to attract the attention of people. The aim in such ostentation is to gain recognition in the estimation of people. It is for this reason that the Shariah describes riya as a form of shirk since the ibadat is not rendered purely for Allah's sake, but others are included in the motive underlying the worship.
This attitude is entirely in negation of Ikhlaas (sincerity) and it eliminates the object of ibaadat which is solely the Pleasure of Allah Ta'ala or goals permitted by Allah Ta'ala, e.g. Thawaab in the Aakhirah, Jannat and salvation from Punishment, etc.
Rasulullah (sallallahu alayhi wasallam) said that an act (of ibaadat) contaminated with even the slightest vestige of riya is unacceptable to Allah Ta'ala.
When engaging in any act of ibaadat neither consciously plan to display it nor conceal it. Render the ibaadat purely for His sake. Think only of Allah's Pleasure. If the thought of riya arises without one's intent, simply discard it. Do not be perturbed by it and regard is as a waswasah of shaitaan whose plot is always to disturb the Mu'min's peace of mind in an attempt to detract him and prevent him from rendering the ibaadat. As long as one knows that the ibaadat was initiated for Allah's sake, one should not heed any stray thoughts of riya entering the mind without one's volition.
Strive to eliminate hubb-e-jah (love for fame and name) from the heart. Riya is a branch of hubb-e-jah. If one detects that there is riya in one's ibaadat, then the remedy is to practise that particular act of ibaadat in abundance. Shaitaan will then become frustrated and despondent. The nafs will get the message and become subdued. Thus the ibaadat which was commenced even with riya will, by abundance of performance, become aadat (habit) which in turn will be transformed into pure Ibaadat.