J2ME Tips - Display text on the low-level user interface

xiaoxiao2021-03-06  53

J2ME Tips - Display text on the low-level user interface

From: http://blog.9cbs.neet/mailbomb

In the development of J2ME's low-level user interface, it is often encountered to display a large number of texts on Canvas, such as information about interfaces, game descriptions, game announcements. If you are designing, fix the content and length of the text, which is not conducive to the modification is also not conducive to maintenance. Here is a simple way to achieve a simple and maintainable way.

Implementation: 1. All information you need to display is made into a string.

2. Write a method for converting the string into a string array as required.

3. Displayed the converted array in a cycle in Canvas.

Through this three steps, when modifying the displayed information, you only need to modify the string containing the display information, and the method written by yourself can re-split a new string according to the previous criteria. If you need to modify the number of characters displayed per line, you only need to modify your own writing method.

Through such an implementation, it is easy to implement some long text information, even if it is a variable length string.

If you have other better implementations, please communicate.

转载请注明原文地址:https://www.9cbs.com/read-56568.html

New Post(0)