If the king is in check, and the piece that is holding it in check is directly adjacent from the king, can the king take it?
So long as capturing the checking piece would not also cause the King to be in check, yes!
In the position below, the White Queen is giving check. After
...Kxf7, the Black King is no longer in check, so it is indeed a legal move.
[FEN "rnbqkb1r/pppp1Qpp/5n2/4p3/4P3/8/PPPP1PPP/RNB1KBNR b KQkq - 0 0"] 1...Kxf7
However, it is illegal to make any move that places your own King in check. If you did, the opponent would be able to capture your King immediately. Since you can never actually capture a King in a game of Chess, making a move that would allow it is illegal.
So, if White's Queen is "protected" by another piece (such as a Bishop, below), the Black's King cannot capture it, as doing so would leave his King still in check. In fact, in the position below (the "scholar's mate"), Black is checkmated because he has no moves that would not result in his still being in check.
[FEN "r1bqkb1r/pppp1Qpp/2n2n2/4p3/2B1P3/8/PPPP1PPP/RNB1K1NR b KQkq - 0 0"] 1...Kxf7 2.Bxf7
Remember that in the position above,
1...Kxf7 2.Bxf7 are given as examples: neither move is actually legal, as Black is already checkmated in the starting position!