  We present accurate measurements of the total HI mass in dark matter halos of
different masses at z ~ 0, by stacking the HI spectra of entire groups from the
Arecibo Fast Legacy ALFA Survey. The halos are selected from the optical galaxy
group catalog constructed from the Sloan Digital Sky Survey DR7 Main Galaxy
sample, with reliable measurements of halo mass and halo membership. We find
that the HI-halo mass relation is not a simple monotonic function, as assumed
in several theoretical models. In addition to the dependence of halo mass, the
total HI gas mass shows strong dependence on the halo richness, with larger HI
masses in groups with more members at fixed halo masses. Moreover, halos with
at least three member galaxies in the group catalog have a sharp decrease of
the HI mass, potentially caused by the virial halo shock-heating and the AGN
feedback. The dominant contribution of the HI gas comes from the central
galaxies for halos of $M<10^{12.5}h^{-1}M_{\odot}$, while the satellite
galaxies dominate over more massive halos. Our measurements are consistent with
a three-phase formation scenario of the HI-rich galaxies. The smooth cold gas
accretion is driving the HI mass growth in halos of
$M<10^{11.8}h^{-1}M_{\odot}$, with late-forming halos having more HI accreted.
The virial halo shock-heating and AGN feedback will take effect to reduce the
HI supply in halos of $10^{11.8}h^{-1}M_{\odot}<M<10^{13}h^{-1}M_{\odot}$. The
HI mass in halos more massive than $10^{13}h^{-1}M_{\odot}$ generally grows by
mergers, with the dependence on halo richness becoming much weaker.
