If you want to fly in Minecraft while you are playing the game, you need to turn on creative mode from the settings menu.
1. During the game, press the Pause button (at the top).
2. Press the Settings button (on the left).
3. Under Default Game Mode, click the check box for Creative Mode.
4. After you change the default game mode to Creative, a new option appears for Personal Game Mode. Click this to change this box to Creative.
5. Click the X at the top right to close and return to the menu.
6. Click Resume Game to go back to the game.
You will now be able to fly in Minecraft!