posts - 66,comments - 41,trackbacks - 0
                最近經常發生Android的配置文件(像:AndroidManifest.xml)在ECLIPSE中讀取出錯的情況,報錯情況如下:
            
          Could not open the editor: The editor class could not be instantiated. This usually indicates a missing no-arg constructor or that
          the editor
          's class name was mistyped in plugin.xml.
               這個問題可能是由于編輯器是用JDK1.5編譯而造成的,而我使用的是JDK1.6。
               我把JDK設置成1.5后問題解決了(方法:Windows->Preferences->Java->Compiler->Compiler compliance level:1.5)。
               如圖所示:
           

          posted @ 2009-04-29 21:04 kylixlu 閱讀(1294) | 評論 (0)編輯 收藏
          http://www.aygfsteel.com/Files/kylixlu/NMEA0183.7z
          posted @ 2009-04-22 20:13 kylixlu 閱讀(416) | 評論 (0)編輯 收藏
          http://java.sun.com/blueprints/patterns/catalog.html
          posted @ 2009-04-15 20:33 kylixlu 閱讀(135) | 評論 (0)編輯 收藏
          1. 打開 Android的模擬器,%Android_HOME%\tools\emulator.exe
          2. 打開一個COMMAND窗口,輸入:adb shell 連接模擬器
           
          3. 使用"cd"命令將當前目錄調整成  ../data/com.android.providers.settings/databases (注意是'/')
           
          4.我們使用'ls'命令可以看到有個settings.db數據文件
           
          5.使用'sqlite3'連接這個數據文件
           
          6.我們來查看一下數據庫和庫中的表單
           

           

          7.用Insert語句往system表中插入proxy的設置(e.g:Insert into system Values(_id,'http_proxy','IPAddress:port');)
           

          8.我們可以用'Select * From system'來查看一下我們插入的配置,下圖可以看到我們插入那個配置
           

          9.刪除這個配置(e.g:Delete From system Where _id=1984)

           
            我們可以再用'Select * from system',查看一下這個數據庫,如下圖可見,我們插入的配置已經刪除了,不過我試了一下,好像要重啟一下模擬器,才能使用新的配置,不知道是不是我機器的問題,沒有仔細研究。
           



          posted @ 2009-03-12 15:30 kylixlu 閱讀(1408) | 評論 (0)編輯 收藏

          復習多線程,一個經典的實例:生產者消費者問題:

          1.number表示產品編號,flag表示現在應該由誰來操作.

          2.ProcuctData類中有兩個同步方法setNumber()和getNumber(),分別代表生產者生產產品和消費者消費 產品。

          3.兩個線程類Producer和Consumer分別代表生產者與消費者

          Java代碼
          1. package cn.luxsoft.javafirststep.Thread;  
          2.   
          3. class ProductData {  
          4.   
          5.     // 產品編號  
          6.     private int number;  
          7.   
          8.     // 標記位  
          9.     private boolean flag = true;  
          10.   
          11.     public synchronized void setNumber(int number) {  
          12.         if (!flag) {  
          13.             try {  
          14.                 // 末消費等待  
          15.                 wait();  
          16.             } catch (InterruptedException e) {  
          17.                 e.printStackTrace();  
          18.             }  
          19.         }  
          20.         this.number = number;  
          21.   
          22.         // 標記已經產生  
          23.         flag = false;  
          24.   
          25.         // 通知消費者已經生產,可以消費  
          26.         notify();  
          27.     }  
          28.   
          29.     public synchronized int getNumber() {  
          30.         if (flag) {  
          31.             try {  
          32.                 // 未生產等待  
          33.                 wait();  
          34.             } catch (InterruptedException e) {  
          35.                 e.printStackTrace();  
          36.             }  
          37.         }  
          38.   
          39.         // 標記已消費  
          40.         flag = true;  
          41.   
          42.         // 通知需要生產  
          43.         notify();  
          44.         return this.number;  
          45.     }  
          46. }  
          47.   
          48. class Procucer extends Thread {  
          49.     private ProductData s;  
          50.   
          51.     Procucer(ProductData s) {  
          52.         this.s = s;  
          53.     }  
          54.   
          55.     @Override  
          56.     public void run() {  
          57.         for (int i = 0; i < 10; i++) {  
          58.             s.setNumber(i);  
          59.             System.out.println("P[" + i + "]生產.");  
          60.         }  
          61.     }  
          62. }  
          63.   
          64. class Consumer extends Thread {  
          65.     private ProductData s;  
          66.   
          67.     Consumer(ProductData s) {  
          68.         this.s = s;  
          69.     }  
          70.   
          71.     public void run() {  
          72.         int i;  
          73.   
          74.         do {  
          75.             i = s.getNumber();  
          76.             System.out.println("P[" + i + "]消費.**");  
          77.         } while (i != 9);  
          78.     }  
          79. }  
          80.   
          81. public class ProducerConsumer {  
          82.   
          83.     /** 
          84.      * @param args 
          85.      */  
          86.   
          87.     public static void main(String[] args) {  
          88.   
          89.         ProductData s = new ProductData();  
          90.         Thread producer = new Procucer(s);  
          91.         Thread consumer = new Consumer(s);  
          92.   
          93.         producer.start();  
          94.         consumer.start();  
          95.     }  
          96.   
          97. }  

          文章來源:http://www.my1984.net/?action=show&id=177
          posted @ 2009-03-08 17:12 kylixlu 閱讀(794) | 評論 (0)編輯 收藏
          僅列出標題
          共14頁: 上一頁 1 2 3 4 5 6 7 8 9 下一頁 Last 
          主站蜘蛛池模板: 清河县| 巴东县| 凭祥市| 佛学| 商水县| 江门市| 穆棱市| 吴忠市| 时尚| 德阳市| 临沧市| 霍邱县| 工布江达县| 永福县| 威远县| 宜城市| 绥宁县| 蓬溪县| 五华县| 新建县| 綦江县| 天柱县| 日喀则市| 新邵县| 桐庐县| 大港区| 安乡县| 西城区| 星座| 光山县| 榆林市| 潜山县| 收藏| 伊春市| 蓝山县| 丹凤县| 历史| 抚宁县| 阿拉善右旗| 横山县| 武山县|