最近經常發生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 閱讀(1286) |
評論 (0) |
編輯 收藏
http://www.tkk7.com/Files/kylixlu/NMEA0183.7z
posted @
2009-04-22 20:13 kylixlu 閱讀(406) |
評論 (0) |
編輯 收藏
http://java.sun.com/blueprints/patterns/catalog.html
posted @
2009-04-15 20:33 kylixlu 閱讀(129) |
評論 (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 閱讀(1399) |
評論 (0) |
編輯 收藏
復習多線程,一個經典的實例:生產者消費者問題:
1.number表示產品編號,flag表示現在應該由誰來操作.
2.ProcuctData類中有兩個同步方法setNumber()和getNumber(),分別代表生產者生產產品和消費者消費 產品。
3.兩個線程類Producer和Consumer分別代表生產者與消費者
Java代碼
- package cn.luxsoft.javafirststep.Thread;
-
- class ProductData {
-
-
- private int number;
-
-
- private boolean flag = true;
-
- public synchronized void setNumber(int number) {
- if (!flag) {
- try {
-
- wait();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- this.number = number;
-
-
- flag = false;
-
-
- notify();
- }
-
- public synchronized int getNumber() {
- if (flag) {
- try {
-
- wait();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
-
-
- flag = true;
-
-
- notify();
- return this.number;
- }
- }
-
- class Procucer extends Thread {
- private ProductData s;
-
- Procucer(ProductData s) {
- this.s = s;
- }
-
- @Override
- public void run() {
- for (int i = 0; i < 10; i++) {
- s.setNumber(i);
- System.out.println("P[" + i + "]生產.");
- }
- }
- }
-
- class Consumer extends Thread {
- private ProductData s;
-
- Consumer(ProductData s) {
- this.s = s;
- }
-
- public void run() {
- int i;
-
- do {
- i = s.getNumber();
- System.out.println("P[" + i + "]消費.**");
- } while (i != 9);
- }
- }
-
- public class ProducerConsumer {
-
-
-
-
-
- public static void main(String[] args) {
-
- ProductData s = new ProductData();
- Thread producer = new Procucer(s);
- Thread consumer = new Consumer(s);
-
- producer.start();
- consumer.start();
- }
-
- }
文章來源:
http://www.my1984.net/?action=show&id=177
posted @
2009-03-08 17:12 kylixlu 閱讀(790) |
評論 (0) |
編輯 收藏