You are quite right that smartphones can indeed be infected with viruses and other forms of malware.
This has been a major concern for a few phone manufacturers and phone companies for many years.
"Hutchinson 3" virtually killed the Motorola A920 when it was first launched as they were really concerned that their network could be brought down if somebody created a virus for Symbian and spread it through the A920's (so they turned off all the useful features, like Bluetooth, GPS, etc), later they realised they'd gone over kill and released a patch to unlock the features.
One of the biggest problems though you have with creating a virus for a mobile phone is the amount of different OS's available for phones.
To write a virus for a phone you would need to write a different code for each phone it's likely to encounter to ensure it would run, as many different phones have different OS's, here are a few - Symbian (mainly found on Nokia's), iPhone OS (Apple), Windows Mobile (various versions) (HTC, Samsung, Sony Ericsson), and Android (various versions) (HTC, Motorola, Samsung, LG, Sony Ericsson).
They are just the major ones there are also a variety of other ones (like some Samsung smartphones use Samsung's version of Linux as an OS). Also even though some are running the same OS, the OS's are tweaked for that specific phone as well, so something that runs on a Sony Ericcson X1, might not work fully with a HTC HD, even though they are both running Windows Mobile 6.1, and an HD2 would be a totally different ball game as that is running Windows Mobile 6.5 (unless it's a hacked one running Windows Mobile 7.0 or even Android!)
So on a phone it's not quite as easy to write a virus as it is for a Windows PC, also the reason why Windows is targeted far more than other OS's for viruses - there are far more Windows users out there than other OS's like Linux, Unix, or Mac OS, so by putting a virus out for Windows you cover quite a large base of users.
However with phones not one smartphone OS actually has a big enough share, the iPhone OS is getting pretty close, plus you also have security in the OS.
Windows OS is quite easily targeted by virus creators due to it's lack of security, it makes itself easy for the end user to use but obviously by making it easy to use it opens up various security holes, thus allowing viruses to enter.
Apple are really restrictive on what you can and can't do in their iPhone OS, which whilst annoying some power users on this, it does protect the end user from accidentally installing a virus, this includes things like restricting Codecs the phone can use, no Flash, and various other methods to keep the end user safe.
And finally one other thing that you will note about most smartphones, unlike computers if they do get a virus, most smartphones come with a handy "reset" button somewhere that resets the OS to how it was when it left the factory, whilst keeping all other data, like pictures and music safe (or most smartphones also sync the settings to a PC, so if they go wrong you can always reset and sync the smartphone the other way to get all your data back), so even if you were to get a virus on your smartphone you can always just reset it, unlike PC's where in the case of some severe viruses you have to backup and wipe everything.