Praise be to Allah.
The one who wants to stop himself showing off has to do the following things to rid himself of this problem:
He should remember that Allaah is always watching His slave.
This is the status of ihsaan (perfection in worship) which Jibreel (peace be upon him) mentioned to the Prophet (peace and blessings of Allaah be upon him), which is that you should worship Allaah as if you can see Him, and even though you cannot see Him, He can see you. (Narrated by Muslim, 97).
When a person feels that Allaah is always watching him, what other people think will become insignificant, and this will make him respect and fear only Allaah.
Seeking the help of Allaah to rid himself of the habit of showing off.
Allaah says that the believers should say (interpretation of the meaning):
You (Alone) we worship, and You (Alone) we ask for help (for each and everything) [al-Faatihah 1:5].
One of the things that will be of benefit in this matter is seeking the help of Allaah and calling upon Him. The Prophet (peace and blessings of Allaah be upon him) said: O people, beware of this shirk (form of polytheism), for it is more subtle than the footsteps of an ant. The one whom Allaah willed should speak said to him, How can we beware of it when it is more subtle than the footsteps of an ant, O Messenger of Allaah? He said, Say, Allaahumma innaa naoodhu bika min an nushrika bika shayan nalamuhu wa nastaghfiruka limaa laa nalam (O Allaah, we seek refuge with You from knowingly associating anything with You, and we seek Your forgiveness for that which we do unknowingly).
(Narrated by Ahmad, 4/403; classed as saheeh (authentic) by Shaykh al-Albaani in Saheeh al-Jaami, 3731).
Knowing the effects of showing off and how it will be judged in the Hereafter.
Not knowing this leads to one falling into this sin or persisting in it. One should realize that showing off destroys all one's actions (i.e., cancels out the reward), and that it brings the wrath of Allaah. The wise person does not waste his energy in doing things that do not bring any reward, let alone deeds that bring the wrath and anger of Allaah.
One of the greatest ahaadeeth (prophetic narrations)concerning the punishment in the Hereafter of those who show off is the following, in which the Prophet (peace and blessings of Allaah be upon him) said:
When the Day of Resurrection comes, Allaah, may He be blessed and exalted, will come down to judge between His slaves, and every nation will be kneeling. The first ones to be called forth will be a man who learned the Quraan by heart, a man who fought for the sake of Allaah, and a man who had a lot of wealth. Allaah will say to the Quraan-reader, Did I not teach you that which I revealed to My Messenger? He will say, Yes, O Lord. He will say, What did you do with that which I taught you? He will say, I used to read it night and day. Allaah will say to him, You have lied, and the angels will say to him, You have lied. Allaah will say, Rather you wanted it to be said that So and so is a reader of Quraan, and that is what was said. Then the wealthy man will be brought forth, and Allaah will say to him, Did I not give you ample provision so that I did not leave you in need of anybody? He will say, Yes, O Lord. He will say, What did you do with that which I gave you? He will say, I used to uphold the ties of kinship and give in charity. Allaah will say to him, You have lied, and the angels will say to him, You have lied. Allaah will say, Rather you wanted it to be said that So and so is generous, and that is what was said. Then the one who was killed for the sake of Allaah (apparently) will be brought forth and Allaah will say to him, Why were you killed? He will say, I was commanded to fight in Jihaad (battle) for Your sake, so I fought until I was killed. Allaah will say to him, You have lied, and the angels will say to him, You have lied. Allaah will say, You wanted it to be said that So and so was courageous, and that is what was said. Then the Messenger of Allaah (peace and blessings of Allaah be upon him) struck my knee and said, O Abu Hurayrah, these three are the first of the creation of Allaah who will be dragged into the Fire on the Day of Resurrection.
(Narrated and classed as hasan (sound)by al-Tirmidhi, 2382; classed as saheeh by Ibn Hibbaan, 408, and Ibn Khuzaymah, 2482).
Thinking about the punishment in this world for showing off
Just as there will be a punishment in the Hereafter for showing off, so too there is a punishment for it in this world, which is that Allaah will expose him and make his bad intentions known to others. This is one of the interpretations of the hadeeth of the Prophet (peace and blessings of Allaah be upon him):
Whoever shows off, Allaah will expose him. (Narrated by al-Bukhaari, 6134; Muslim; 2986).
Ibn Hajar said: al-Khattaabi said, this means: whoever does something that is not sincerely for the sake of Allaah, merely wanting people to see him and hear him, will be punished for that Allaah will expose him and make known what he is concealing.
It was said that whoever does something with the intention of gaining status and prestige among people, and does not seek the Face of Allaah by doing it, Allaah will make him the subject of bad speech among the people in whose eyes he wanted to gain status, and he will have no reward for it in the Hereafter. (Fath al-Baari, 11/336)
Concealing worship and not making a display of it
The further away a person gets from places where his worship can be seen, the safer he is from showing off. Whoever looks for places where people gather, the Shaytaan makes him keen to show off his worship so that they will praise him for it.
The acts of worship which should be hidden are those which are not obligatory or those in which it is not the Sunnah to do them openly, such as Qiyaam al-Layl (night prayer), and giving charity, and the like. This does not apply to calling the Adhaan (call to prayer),praying in congregation and other things which cannot and should not according to shareeah (Islamic law) be hidden.
We ask Allaah to make our words and deeds sincere, and to forgive us for what we commit of showing off. May Allaah bless our Prophet Muhammad.