lwuit ---一些细节疑难杂症整理笔记
2010-04-29 10:39
441 查看
1、textArea 显示文本内容,在部分手机上无法显示全部内容,每一行的最后几个字被挡住
琢磨了很久终于找了出来,解决方案如下:
2、若要对文本框中的内容设置补丁:
内容往右10像素
3、如果list上不想要显示文字多余时的省略号
4、重写Dialog要让标题与Form的样式一致
5、声音播放
6、使得TextField也能够在触屏手机上点击时出现输入编辑
解决方法:
在TextField源码上 加上editString();函数:
或者官方的解决方法:http://forums.java.net/jive/thread.jspa?threadID=52716
7、震动
8、导致内存激增的原因(可以用自动模拟器的内存检测器进行监测C:\WTK2.5.2\bin\prefs.exe将你要的设置勾选)
而lwuit里面的源码有两句是会导致内存一直占用,一个是TextField中的这段代码
一个是Display
lwuitGraphics.setGraphics(impl.getNativeGraphics());
这两个暂时还没有仔细去研究,但是确实吃内存的所在。
还有就是要巧用System.gc();进行内存回收,这样就会尽量的减少内存溢出的情况。
9、滚动条拖拽方向与内容显示相反,component中的代码修改如下
10、开启wtk模拟器的触摸屏功能
打开\wtklib\devices\DefaultColorPhone目录下的DefaultColorPhone.properties文件(最好先安装一个UltraEdit之类的文本编辑器)。
然后找到touch_screen选项,修改为touch_screen=true
11、设置模拟器权限,以免开发过程中弹出烦人的提示
打开wtk模拟器。
选择Edit->Preferences->Security
然后将Security domain的选项设置为maximum。
12、内存和性能监视器
Edit->Preferences->Memory Monitor
Edit->Preferences->Profiler
13、出现安装后无法打开问题
有些Nokia手机会出现安装后无法打开,原因是安装包名称包含中文导致。
14、想要保存Sun Java (TM) Wireless Toolkit 2.5.2 for CLDC模拟器的RMS值,可以通过Preference - 存储(s)存储根目录 :(例:/disk) 来设置.
(选择你想要用的模拟器)然后到C:\Documents and Settings\Administrator\j2mewtk\2.5.2\appdb\DefaultColorPhone\filesystem\root1 建disk文件夹。
15、在S60 3th FP2版本上会出现String Index Out of Bounds Exception;原因DefaultLookAndFeel.java,在计算字符超过屏幕时出现异常。
int widest = f.charWidth('W');必须改成int widest = f.charWidth('一');
16、如果客户端创建出现cvs [server aborted]: "add" requires write access to the repository,将服务器端的CVSNT Advanced的All user are read即可.
以上内容转自:/article/5807386.html
琢磨了很久终于找了出来,解决方案如下:
TextArea txtContent = new TextArea(strContent, 12, 24); //添加这一句即可 txtContent.setWidestChar('一');
2、若要对文本框中的内容设置补丁:
txtContent.getStyle().setPadding(Component.RIGHT, 10);
内容往右10像素
3、如果list上不想要显示文字多余时的省略号
name.setEndsWith3Points(false);
4、重写Dialog要让标题与Form的样式一致
dialog.show(100, 100,100,100, true);
5、声音播放
try { InputStream is = getClass().getResourceAsStream( "/res/NewMailSound.wav"); Player player = Manager.createPlayer(is, "audio/x-wav"); player.start(); } catch (Exception e) { e.printStackTrace(); }
6、使得TextField也能够在触屏手机上点击时出现输入编辑
解决方法:
在TextField源码上 加上editString();函数:
public void pointerReleased(int x, int y) { // unlike text area the text field supports shifting the cursor with the touch screen editString(); String text = getText(); int textLength = text.length(); int position = 0; Font f = getStyle().getFont(); x -= getAbsoluteX(); for(int iter = 0 ; iter < textLength ; iter++) { int width = f.substringWidth(text, 0, iter); if(x > width) { position = iter; } else { break; } } if(position == textLength - 1) { if(f.stringWidth(text) < x) { position = textLength; } } setCursorPosition(position); repaint(); }
或者官方的解决方法:http://forums.java.net/jive/thread.jspa?threadID=52716
7、震动
public void MakeVibrate() { new Thread() { public void run() { try { Display.getInstance().vibrate(2000); } catch (Exception e) { e.printStackTrace(); } } }.start(); }
8、导致内存激增的原因(可以用自动模拟器的内存检测器进行监测C:\WTK2.5.2\bin\prefs.exe将你要的设置勾选)
而lwuit里面的源码有两句是会导致内存一直占用,一个是TextField中的这段代码
// public boolean animate() { // boolean ani = super.animate(); // if (hasFocus()) { // long currentTime = System.currentTimeMillis(); // if (drawCursor) { // if ((currentTime - cursorBlinkTime) > blinkOnTime) { // cursorBlinkTime = currentTime; // drawCursor = false; // return true; // } // } else { // if ((currentTime - cursorBlinkTime) > blinkOffTime) { // cursorBlinkTime = currentTime; // drawCursor = true; // return true; // } // } // if (pressedAndNotReleased) { // if (currentTime - pressTime >= getLongClickDuration()) { // longClick(pressedKeyCode); // } // } else { // if (pendingCommit && currentTime - releaseTime > commitTimeout) { // commitChange(); // } // } // } else { // drawCursor = false; // } // return ani; // }
一个是Display
lwuitGraphics.setGraphics(impl.getNativeGraphics());
这两个暂时还没有仔细去研究,但是确实吃内存的所在。
还有就是要巧用System.gc();进行内存回收,这样就会尽量的减少内存溢出的情况。
9、滚动条拖拽方向与内容显示相反,component中的代码修改如下
public void pointerDragged(int x, int y) { if (isScrollable() && isSmoothScrolling()) { int axisValue; if (isScrollableY()) { axisValue = y; } else { axisValue = x; } if (!dragActivated) { dragActivated = true; beforeLastScrollY = axisValue; lastScrollY = axisValue; getComponentForm().setDraggedComponent(this); } //save time and locations to create velocity when the //pointer is released long currentTime = System.currentTimeMillis(); if (currentTime != lastTime[(pLastDragged + lastTime.length + 1) % lastTime.length]) { lastTime[pLastDragged] = System.currentTimeMillis(); lastDragged[pLastDragged] = axisValue; pLastDragged = (++pLastDragged) % lastTime.length; } beforeLastScrollY = lastScrollY; lastScrollY = axisValue; // we drag inversly to get a feel of grabbing a physical screen // and pulling it in the reverse direction of the drag if (isScrollableY()) { int scroll = getScrollY() - (beforeLastScrollY - axisValue); if (scroll >= 0 && scroll < getPreferredH() - getHeight()) { setScrollY(scroll); } } else { int scroll = getScrollX() - (beforeLastScrollY - axisValue); if (scroll >= 0 && scroll < getPreferredW() - getWidth()) { setScrollX(scroll); } } } else { //try to find a scrollable element until you reach the Form Component parent = getParent(); if (!(parent instanceof Form)) { parent.pointerDragged(x, y); } } }
10、开启wtk模拟器的触摸屏功能
打开\wtklib\devices\DefaultColorPhone目录下的DefaultColorPhone.properties文件(最好先安装一个UltraEdit之类的文本编辑器)。
然后找到touch_screen选项,修改为touch_screen=true
11、设置模拟器权限,以免开发过程中弹出烦人的提示
打开wtk模拟器。
选择Edit->Preferences->Security
然后将Security domain的选项设置为maximum。
12、内存和性能监视器
Edit->Preferences->Memory Monitor
Edit->Preferences->Profiler
13、出现安装后无法打开问题
有些Nokia手机会出现安装后无法打开,原因是安装包名称包含中文导致。
14、想要保存Sun Java (TM) Wireless Toolkit 2.5.2 for CLDC模拟器的RMS值,可以通过Preference - 存储(s)存储根目录 :(例:/disk) 来设置.
(选择你想要用的模拟器)然后到C:\Documents and Settings\Administrator\j2mewtk\2.5.2\appdb\DefaultColorPhone\filesystem\root1 建disk文件夹。
15、在S60 3th FP2版本上会出现String Index Out of Bounds Exception;原因DefaultLookAndFeel.java,在计算字符超过屏幕时出现异常。
int widest = f.charWidth('W');必须改成int widest = f.charWidth('一');
16、如果客户端创建出现cvs [server aborted]: "add" requires write access to the repository,将服务器端的CVSNT Advanced的All user are read即可.
以上内容转自:/article/5807386.html
相关文章推荐
- lwuit ---一些细节疑难杂症整理笔记
- lwuit ---一些细节疑难杂症整理笔记
- LWUIT 一些细节疑难杂症整理笔记
- iOS开发笔记18:一些编译、开发调试、打包的细节整理
- 【学习OpenCV】编程笔记:一些需要注意的细节
- 从事java开发的第四个年头,开始做一些笔记,做一些整理
- Python学习笔记整理(十五)类的编写细节
- TCP/IP详解--学习笔记(5)-IP选路,动态选路,和一些细节
- 个人笔记-记录一些小的细节即函数用法
- Android 与 Java 中的一些细节(笔记)
- Java学习笔记---基本类型、运算优先级的一些知识整理
- 菜鸟学Android笔记(二十二):Servlet的一些细节
- python笔记和一些问题(未整理)
- 关于linux进程编程的一些笔记整理
- TCP/IP详解--学习笔记(5)-IP选路,动态选路,和一些细节
- 关于RCP的一些整理笔记
- PS的一些小细节(笔记)
- 关于java的一些细节问题,笔试可能会问到,整理一下
- Spring4 学习笔记(4)-Spring 属性配置的一些细节
- 关于linux进程编程的一些笔记整理