lwuit ---一些细节疑难杂症整理笔记
生活随笔
收集整理的這篇文章主要介紹了
lwuit ---一些细节疑难杂症整理笔记
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1、textArea 顯示文本內容,在部分手機上無法顯示全部內容,每一行的最后幾個字被擋住琢磨了很久終于找了出來,解決方案如下: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 screeneditString();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中的這段代碼Code一個是DisplaylwuitGraphics.setGraphics(impl.getNativeGraphics());這兩個暫時還沒有仔細去研究,但是確實吃內存的所在。還有就是要巧用System.gc();進行內存回收,這樣就會盡量的減少內存溢出的情況。9、滾動條拖拽方向與內容顯示相反,component中的代碼修改如下Code10、開啟wtk模擬器的觸摸屏功能打開\wtklib\devices\DefaultColorPhone目錄下的DefaultColorPhone.properties文件(最好先安裝一個UltraEdit之類的文本編輯器)。然后找到touch_screen選項,修改為touch_screen=true11、設置模擬器權限,以免開發過程中彈出煩人的提示打開wtk模擬器。選擇Edit->Preferences->Security然后將Security domain的選項設置為maximum。12、內存和性能監視器Edit->Preferences->Memory MonitorEdit->Preferences->Profiler13、出現安裝后無法打開問題有些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文件夾。若出現了已經設置好后,仍然不能起到保存作用,到C:\Documents and Settings\Administrator\j2mewtk\2.5.2\appdb\disk 中將相應的RMS文件刪除即可。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即可.17、NokiaS60手機出現string index異常的原因。com.sun.lwuit.Font.charWidth(char)1、TextArea ?line:186private static char widestChar = '國';2、HTMLTextArea ?line:33private static char widestChar = '一';3、DefaultLookAndFeel ?line:1124int widest = f.charWidth('國');?
轉載于:https://blog.51cto.com/zhaohaiyang/435612
總結
以上是生活随笔為你收集整理的lwuit ---一些细节疑难杂症整理笔记的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ubuntu下安装openfetion
- 下一篇: 放弃相爱,并不放弃彼此