Recently, several smart phones are equipped with a 3D-accelerometer that can be used for gesture-based user interface (UI). In order to utilize the gesture UI for the real-time systems with various users, the diversity robust algorithm, yet having low training/recognition complexity, is required. Meantime, dynamic time warping (DTW) has shown good performance on the simple time-series pattern recognition problems. Since DTW is based on the template matching, its processing time and accuracy depend on the number of templates and their quality, respectively. In this paper, an optimized method for online gesture UI of mobile devices is proposed which is based on the DTW and modified k-means clustering algorithm. The templates, estimated by using the modified clustering algorithm, can preserve the time varying attribute while contain diversities of the given training patterns. The proposed method was validated on 20 types of gestures which are designed for the mobile contents browsing. The experimental results showed that the proposed method is suitable to the online mobile UI.