The question was formulated in the context of a jet liner such as the Boeing 737-800 or the Airbus, I do not understand why there are persons responding to this question in the context of a smaller less complex aircraft.
With that being said, I will like to expand the answer by DeltaLima. Boeing uses a device attached to the Brake Metering Valve Module called a De-spin Actuator. This device directs controlled hydraulic fluid to the brakes when the landing gear lever is set to retract to stop the spinning of the wheels. More information can be found in the AMM ATA 32 (Aircraft Maintenance Manual Chapter on Landing Gear).
https://www.facebook.com/aviationisawesome/videos/1598830786833154/
Video of a 737-500 from inside the main gear wheel well shows:
- After becoming airborne, the landing gear suspension unloads and the wheel hangs down, still spinning
- Once the main gear arms begin retracting, the wheel stops within a second
- The gear has fulled retracted in 6-7 seconds.
De-Spin Actuator
Source: http://www.eaton.com/ecm/groups/public/@pub/@eaton/@aero/documents/content/ct_194202.pdf