what are the little pillbox hats that some Africans wear called?

Depends on the shape. Képi or fez. Tarboosh is another word for them. (Thank you, thank you, Edgar Wallace, fount of all African wisdom. Ha!)

Also snapbrim, fedora.