I used a pretty stiff wire brush. You need to get all of the old material and foam off of so you have a good surface for the glue to adhere. If you are using actual headliner material with the foam backed cloth you will want the backing piece as smooth as you can get it.
Start in the middle with a piece of material big enough to have excess on every side, spray some 3M spray adhesive on the backing and the new foam material and start in the middle and work your way to the outside, spraying and putting down a little bit at a time. Don't stretch it in the middle area where there are contours or it will make air pockets. Take your time, work slow and use lots of glue on both sides.