With tremendous computing power in the radio access network, mobile edge computing (MEC) that can support localized context awareness creates a new technological frontier for 5G and beyond. To efficiently exploit the networking and computing functionalities, Time Division Duplex Orthogonal Frequency Division Multiple Access (TDD-OFDMA) type has been considered in this paper. To take advantage of dynamic features in TDD, a model-free online TDD configuration scheme is proposed based on context analysis and Multi-Armed Bandit (MAB) optimization. The TDD configuration problem is therefore novelly modeled as a contextual MAB problem, and is solved by the contextual Upper-Confidence-Bound (C-UCB), which dynamically adjusts TDD configuration to network traffic since that the system cost can be reduced. To further reduce the energy consumption and makespan of mobile devices (MDs), a greedy resource allocation (GRA) embedded in the TDD configuration is developed to select MDs and allocate resources. The simulations demonstrate that proper TDD configuration successfully reduces the system cost, and C-UCB technique approaches the ideal TDD configuration, with significant performance gain when the GRA effectively select and allocate, to strike simultaneous efficiency for mobile networking and MEC.