posts - 11,  comments - 21,  trackbacks - 0

          使用eclipse的nodejs的插件,右鍵運行app.js,控制臺一閃而過,沒有啟動起來.

          通過搜索,發現原來是JDK版本的問題,我用的是JDK6,不好使,使用JDK7就好使了.

          如果有多個JDK版本共存,可以使用在eclipse安裝目錄下的文件eclipse.ini指定要使用的JDK:

          -vm
          C:/Program Files/Java/jdk1.7.0_55/bin/javaw.exe

          posted @ 2014-04-25 03:52 xmlspy 閱讀(225) | 評論 (0)編輯 收藏

          很多人在安裝完Eclipse之后什么都不設置,直接用默認的設置,默認的設置有很多問題。
          在項目管理中應該統一Eclipse的設置。

          通過菜單Window->Preferences打開設置窗口。

          • General->Editors->Text Editors:
            選上Insert spaces for tabs : 縮進使用空格,不使用Tab.原因是當把代碼復制給網絡上的顯示的時候,
            Tab經常會被刪除,導致格式完全亂套.
            選上Show line numbers : 顯示行號,這個在debug的時候快速定位非常方便.
            選上Show print margin,然后在下面的Print margin column輸入框中輸入120 : 顯示一條豎線,
            用于標示打印機打印時的寬度.這里用于代碼自動換行的寬度. 設置為120個字符.這個同樣在Java
            代碼格式化的時候用到,后繼會說到.
            Y3RDP4``Q@][2]JX]3DYVA7[4]
          • General->Workspace
            在Text file encoding中選擇Other,然后在下拉框中選UTF-8 : 這樣所有項目都是用UTF-8編碼.默認的是GBK.
          • Java->Code Style->Formatter
            這里是Java代碼格式化相關的選項, 要修改默認的設置,需要新建一個配置.

            點擊按鈕 New… 在彈出框中的 Profile name 輸入框輸入新配置的名稱,這里輸入 11, 然后點擊OK按鈕.
            在新彈出的配置窗口中,選擇標簽Indentation, 在Tab policy下拉框中選擇 Spaces only : 縮進使用空格.
            這里需要注意,如果在General->Editors->Text Editors中選擇了Insert spaces for tabs, 而在格式化選項中
            沒有改成使用空格,那么在Java代碼格式化后,仍然使用Tab.

            選擇標簽 Line Wrapping,在Maximum line width輸入框輸入120 : 在120個字符后換行, 上面的 Print margin column
            也用的120,這樣就知道換行的標示了.

          其他如果有Editor的地方,縮進也都要改成4個空格. 比如: Web節點下面的CSS Files, HTML Files.

          posted @ 2013-11-17 15:32 xmlspy 閱讀(2716) | 評論 (2)編輯 收藏

          使用這個東西的好處是,可以發布到多個Blog上,免得使用Web編輯器苦逼地編輯.

          下載地址: http://windows.microsoft.com/zh-cn/windows-live/essentials-other#essentials=overviewother

          * 使用Live Writer在oschina上寫Blog: http://my.oschina.net/javayou/blog/39107

          * 使用Live Writer在BlogJava上鞋Blog: http://www.aygfsteel.com/vulcan/archive/2010/11/05/337323.html

          注意:  - 在日志類型中選擇Metaweblog API

                    - API連接為: http://www.aygfsteel.com/你的blog名稱/services/metaweblog.aspx

          posted @ 2013-10-02 22:46 xmlspy 閱讀(230) | 評論 (0)編輯 收藏

          更新了最新Android ADT工具后,出現 TypeError: argument of type 'NoneType' is not iterable.

          O{J4%Z8HX[DQ%ORWFHNWGUC

          解決:

              復制 build-tool/17.0.0/ 下所有內容到 platform-tools 目錄下.

          參考:

          https://developer.appcelerator.com/question/152497/titanium-sdk-310-error-typeerror-argument-of-type-nonetype-is-not-iterable-on-building-android-app

          posted @ 2013-05-31 09:05 xmlspy 閱讀(590) | 評論 (0)編輯 收藏

          有時候Titanium中的終端會顯示:

          This Terminal Emulator is not functional because no 'bash' shell could be found.
          
          Please correct the problem and restart the IDE.

          解決辦法:

          • Team / Git / Git Executable (was empty)   --指定正確的git.exe文件位置
          • Titanium Studio / NodeJS / Node Executable (was empty also) ---- 指定NodeJS的node.exe的位置

           

          然后重啟終端就好了.

          posted @ 2013-05-30 19:33 xmlspy 閱讀(222) | 評論 (0)編輯 收藏

          1.目的

          在WebView控件中,如果頁面中調用了javascript腳本console.log 方法,就調用一個Java方法.

           

          2.默認實現方法

          在Android的WebView控件中,有一個setChromeClient(WebChromeClient)方法,

          此方法的參數是WebChromeClient對象,通過重載此對象中的onConsoleMessage方法就

          可以達到此目的.看代碼:

          WebView webView = new WebView();
          webView.setWebChromeClient(new DefaultWebChromeClient);
          
          // 以上代碼放在在Activity或則Fragment中的onCreate方法中
          
          private class DefualtWebChromeClient extends WebChromeClient {
              @Override
              public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
                  String message = consoleMessage.message();
                  int lineNumber = consoleMessage.lineNumber();
                  String sourceID = consoleMessage.sourceId();
                  String messageLevel = consoleMessage.message();
          
                  Log.i("[WebView]", String.format("[%s] sourceID: %s lineNumber: %n message: %s",
                          messageLevel, sourceID, lineNumber, message));
          
                  return super.onConsoleMessage(consoleMessage);
              }
          
              @Override
              public void onConsoleMessage(String message, int lineNumber, String sourceID) {
                  Log.i("[WebView]", String.format("sourceID: %s lineNumber: %n message: %s", sourceID,
                          lineNumber, message));
                  super.onConsoleMessage(message, lineNumber, sourceID);
              }
          }

          第一個方法onConsoleMessage(ConsoleMessage consoleMessage)是新版本的android才有的方法,第二個方法是舊版本的.

          第二個方法已經不推薦使用了,但是在舊版本的android中,仍然需要此方法.所以最好兩個方法都實現.

           

          3.問題

          默認的實現在某些版本的手機中不好使,onConsoleMessage方法死活不被調用

           

          4.解決方案

          使用WebView的addJavascriptInterface方法:

          // 首先,定一個類,叫什么名稱都可以,但是里面的方法名必須與
          // Javascript的console中的方法名對應
          private class Console{
              private static final String TAG="[WebView]";
              public void log(String msg){
                  Log.i(TAG,msg);
              }
          	// 還可以添加其他的方法,比如: warn,assert等等
          }
          
          // 然后,為WebView添加對應的接口
          webView.addJavascriptInterface(new Console, "console");

           

          這個解決方案有一個不好的地方,就是輸出的內容沒有onConsoleMessage方法那么詳細,比如行號,就沒法輸出.

          所以,我們應該在onConsoleMessage好使的時候使用onConsoleMessage,不好使的時候在使用我們自定義的方式.

          那么,如何來判斷onConsoleMessage是否好使呢? 我們可以在程序初始化的時候,先在WebView中運行一下console.log,

          如果onConsoleMessage運行了,就添加一個標記,表示默認的實現是好使的.

          @Override
          public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
              // 這些代碼也可以放到onCreate方法中
          	
              this.webView = (WebView) layout.findViewById(R.id.webview);
              WebSettings webSettings = webView.getSettings();
              webSettings.setJavaScriptEnabled(true);
              
              // Set WebChromeClient
              WebChromeClient webChromeClient = new TestConsoleMessageWebChromeClient();
          	// 先執行console.log,測試是否調用了onConsoleMessage
              webView.loadUrl("javascript:console.log('testConsoleMessage')");
          	
              if (((TestConsoleMessageWebChromeClient)webChromeClient).isConsoleMessageOK()){
          	    // 這里額外使用了一個新的類 TestConsoleMessageWebChromeClient
          		// 如果不適用TestConsoleMessageWebChromeClient,就需要在
          		// DefaultWebChromeClient中添加標記字段 consoleMessageOK,
          		// 這樣如果方法onConsoleMessage好使,那么每次都給consoleMessageOK賦值,
          		// 這個有些多余,也影響性能.
                  webChromeClient = new DefualtWebChromeClient();
              }else{
          	    // onConsoleMessage不好使,就使用這種方式,第二個參數值必須是"console"
                  webView.addJavascriptInterface(new Console(), "console");
              }
              
              webView.loadUrl("http://www.baidu.com");
          
              return super.onCreateView(inflater, container, savedInstanceState);
          }
          
          // 當默認的onConsoleMessage不好使的時候使用的類
          private class Console {
              private static final String TAG = "[WebView]";
          
              public void log(String msg) {
                  Log.i(TAG, msg);
              }
          	// 這里還可以添加其他方法console對象中有的方法,比如 assert
          }
          
          // 默認
          private class DefualtWebChromeClient extends WebChromeClient {
              @Override
              public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
                  String message = consoleMessage.message();
                  int lineNumber = consoleMessage.lineNumber();
                  String sourceID = consoleMessage.sourceId();
                  String messageLevel = consoleMessage.message();
          
                  Log.i("[WebView]", String.format("[%s] sourceID: %s lineNumber: %n message: %s",
                          messageLevel, sourceID, lineNumber, message));
          
                  return super.onConsoleMessage(consoleMessage);
              }
          
              @Override
              public void onConsoleMessage(String message, int lineNumber, String sourceID) {
                  Log.i("[WebView]", String.format("sourceID: %s lineNumber: %n message: %s", sourceID,
                          lineNumber, message));
                  super.onConsoleMessage(message, lineNumber, sourceID);
              }
          }
          
          // 用于測試onConsoleMessage是否調用的類
          private class TestConsoleMessageWebChromeClient extends WebChromeClient {
              private boolean consoleMessageOK = false;
          
              @Override
              public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
                  this.consoleMessageOK = true;
                  return super.onConsoleMessage(consoleMessage);
              }
          
              @Override
              public void onConsoleMessage(String message, int lineNumber, String sourceID) {
                  this.consoleMessageOK = true;
                  super.onConsoleMessage(message, lineNumber, sourceID);
              }
          
              public boolean isConsoleMessageOK() {
                  return this.consoleMessageOK;
              }
          }
          
          posted @ 2013-04-28 01:46 xmlspy 閱讀(3027) | 評論 (0)編輯 收藏

          匿名立即執行函數

             1:  // 方式一,這種方式多用了一個括號,看著別扭
             2:  (function(param) {
             3:      alert(param);
             4:  })(10);
             5:   
             6:  // 方式二,使用 ! 操作符
             7:  !function(param) {
             8:      alert(param);
             9:  }(10);

          使用匿名立即執行函數的好處是,可以避免變量沖突.

          條件判斷

             1:  //========================= 條件判斷
             2:  var sabiable = true;
             3:  //普通方式
             4:  if (sabiable) {
             5:      alert('You are sability!');
             6:  }
             7:   
             8:  //詭異方式,利用 ||和 && 操作符
             9:  // a||b : 只有在a為fasle或者返回false時才會執行b,當a為true時,直接返回a,后面的b不會執行
            10:  // a&&b : 只有在a為true或者返回true時才會執行b,當a為時,直接返回a,后面的b不會執行
            11:   
            12:  // 上面的代碼可以改為:
            13:  sabiable && alert('You are sability!');
          posted @ 2013-04-01 06:57 xmlspy 閱讀(203) | 評論 (0)編輯 收藏

          問題: 以下代碼,tab1的click事件在Android中生效,在iOS不生效

             1:  function ApplicationTabGroup(Window) {
             2:      //create module instance
             3:      var self = Ti.UI.createTabGroup();
             4:   
             5:      //create app tabs
             6:      var win1 = new Window(L('home')), win2 = new Window(L('settings'));
             7:   
             8:      var tab1 = Ti.UI.createTab({
             9:          title : L('home'),
            10:          icon : '/images/KS_nav_ui.png',
            11:          window : win1
            12:      });
            13:      win1.containingTab = tab1;
            14:   
            15:      var tab2 = Ti.UI.createTab({
            16:          title : L('settings'),
            17:          icon : '/images/KS_nav_views.png',
            18:          window : win2
            19:      });
            20:      win2.containingTab = tab2;
            21:   
            22:      self.addTab(tab1);
            23:      self.addTab(tab2);
            24:   
            25:      tab1.addEventListener('click',function(){
            26:          //這個事件在iOS中不會被觸發
            27:      });
            28:   
            29:      return self;
            30:  };
            31:   
            32:  module.exports = ApplicationTabGroup;

          解決方案:

          通過看Titanium附帶的示例程序 Kitcken Sink , 找到了解決方案.

          為TabGroup添加focus事件,然后對事件參數進行判斷,來確定當前被點擊的是那個tab.

           

             1:  function ApplicationTabGroup(Window) {
             2:      //create module instance
             3:      var self = Ti.UI.createTabGroup();
             4:   
             5:      //create app tabs
             6:      var win1 = new Window(L('home')), win2 = new Window(L('settings'));
             7:   
             8:      var tab1 = Ti.UI.createTab({
             9:          title : L('home'),
            10:          icon : '/images/KS_nav_ui.png',
            11:          window : win1
            12:      });
            13:      win1.containingTab = tab1;
            14:   
            15:      var tab2 = Ti.UI.createTab({
            16:          title : L('settings'),
            17:          icon : '/images/KS_nav_views.png',
            18:          window : win2
            19:      });
            20:      win2.containingTab = tab2;
            21:   
            22:      self.addTab(tab1);
            23:      self.addTab(tab2);
            24:   
            25:      self.addEventListener('focus', function(e) {
            26:   
            27:          var info = Titanium.API.info;
            28:   
            29:          // 在iOS中, e.source 是 TabGroup對象,
            30:          // 在Android中,e.source 是 Tab對象
            31:          var src = e.source;
            32:          var tab = e.tab;
            33:          var preTab = e.previousIndex;
            34:   
            35:          // e.tab 是當前獲得焦點的tab
            36:          // e.index 當前獲得焦點的tab的索引,首次為-1
            37:          // e.previousTab 上個tab
            38:          // e.previousIndex 上個tab的索引,首次為null
            39:   
            40:          // On iOS, the "More..." tab is actually a tab container, not a tab. When it is clicked, e.tab is undefined.
            41:          if (!tab) {
            42:              info('在iOS中點擊了"More..."');
            43:              return;
            44:          }
            45:   
            46:          // 首次
            47:          if (!preTab) {
            48:              info('首次進入');
            49:              return;
            50:          }
            51:   
            52:          if (tab === tab1) {
            53:              info('點擊了tab1');
            54:          } else if (tab === tab2) {
            55:              info('點擊了tab2');
            56:          }
            57:      });
            58:   
            59:      return self;
            60:  };
            61:   
            62:  module.exports = ApplicationTabGroup;
          posted @ 2013-03-31 02:54 xmlspy 閱讀(241) | 評論 (0)編輯 收藏

          以下的插件都可以使用Eclipse Marketplace進行查找,安裝.

           

          1. AnyEdit Tools 
            介紹地址: http://marketplace.eclipse.org/content/anyedit-tools#.UQLITyd6OTU
            更新地址: http://andrei.gmxhome.de/eclipse/

            在更新地址中Eclipse3.5-4.2版本的分支里,沒有找到AnyEdit Tools,
            使用Eclipse Marketplace在里面查找anyedit,之后點擊Install按鈕可以安裝.
          2. Eclipse Explorer
            介紹: 主要用于 在操作系統資源管理器打開文件夾. 可以避免以下啰嗦操作:
                    在資源上點擊右鍵然后選擇屬性,然后在復制資源的系統路徑,然后打開系統資源管理器,復制地址,回車…
          3.   Eclipse Color Theme
            介紹: 各種定義好的編輯器代碼顏色模版.
          4.   Java Source Attacher Feature
            介紹: 可以幫助你查找你的jar包的源碼, 這樣在Java編輯器中點擊ctrl+右鍵就可以查看jar包對應類的源碼了,
                    如果找不到會彈出對話框讓你手動指定.
                    這個非常有用,在做Android開發時, Android插件不允許你通過在jar上點擊右鍵->Attach source,
                    搞得好多jar包都無法實時查看方法的注釋,使用這個插件就可以了.
          5.   Eclipse EGit
            介紹: git的Eclipse插件.
          6. Advanced Prototyping tool - Prototyper Free Edition 2.1 (在Marketplace中搜索 Prototyper)
            介紹: 非常好用的 手機、平板、桌面應用和網站的原型設計工具,幾乎支持現在市面上所有類型的手機、平板,如: iPhone、iPad、
                     Android、BlackBerry、WindowsPhone等等。并且有大量可下載的模版和Widget。拖拖拽拽就可以做出原型。
                     TM截圖未命名

                    其實這個不是Eclipse的插件,至少在Marketplace中找到后,無法直接安裝的.不過可以進入頁面中提供的主頁鏈接
                    到這個工具的網站下載.
            網站地址: http://www.justinmind.com/
          posted @ 2013-01-26 03:15 xmlspy 閱讀(1941) | 評論 (0)編輯 收藏

          一安裝插件eclipse就提示
          ?? Properties Search for Eclipse 3.1.x (2.0.0) requires plug-in "org.eclipse.search (3.1.0)", or equivalent.

          靠,搞得我什么插件都安裝不了 :(
          ??

          posted @ 2006-12-13 19:46 xmlspy 閱讀(3281) | 評論 (3)編輯 收藏
          僅列出標題  下一頁

          <2025年5月>
          27282930123
          45678910
          11121314151617
          18192021222324
          25262728293031
          1234567

          常用鏈接

          留言簿(2)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 武胜县| 临夏市| 东乌珠穆沁旗| 景德镇市| 周口市| 华蓥市| 阿巴嘎旗| 化德县| 左云县| 芮城县| 深水埗区| 海阳市| 东乡县| 黎城县| 洛扎县| 清远市| 桐柏县| 通化县| 台安县| 太康县| 洛浦县| 松阳县| 平山县| 兰溪市| 屏边| 甘南县| 江川县| 苏尼特右旗| 洞口县| 宽甸| 侯马市| 建昌县| 怀柔区| 屏东市| 苏尼特左旗| 泾川县| 镇宁| 两当县| 桃源县| 清水县| 临猗县|