HanesBrands has swung to a first quarter profit as margins improved on lower cotton costs and a better product pricing environment.