So, implementing gravity has some prerequisites. A big one is a time keeping system. One good read for time systems is Fix Your Timestep! by gafferongames.com. The time system ties in tightly to the update loop. See deWITTERS Gameloop for info on implementing an update loop (which covers time step too). Once you have an update loop with a delta time for each iteration, you're pretty much ready.
So, you main game will have something like:
update() {
deltaTime = getCurrentTime() - runningTime; //deltaTime is called "frameTime" too
runningTime = getCurrentTime();
mainCharacter.update(deltaTime);
}
and inside that main character update method it'll be like:
update(float deltaTimeInMS) {
if (onSolidGround())
gravity = 0;
else
gravity = GLOBAL_GRAVITY; //note that global gravity is negative
velocity.y += gravity * deltaTimeInMS;
}
Now this is a pretty basic way of doing it, and it'll be passable for simple games. I wouldn't recommend it for larger scale games however.