Time of Update: 2018-12-05
判斷是否是2G還是3G網路public static boolean isConnectionFast(int type, int subType){ if(type==ConnectivityManager.TYPE_WIFI){ System.out.println("CONNECTED VIA WIFI"); return true; }else
Time of Update: 2018-12-05
在controller的實現檔案中,在data source方法裡,調用[tableView dequeueReusableCellWithIdentifier:identifier]就拋出異常,Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant
Time of Update: 2018-12-05
今天發現ExpandableListAdapter 用起來挺麻煩的, 要建很多個map 資料對象,感覺特別煩, 自己索性寫了一個list 的adapter ,自己鼓搗了一下 寫了一個擴充的自訂的Expand 類似QQ的樣子, 其實也沒什麼,主要是繼承 BaseExpandableListAdapter , 這個adpter 跟baseadpter沒什麼區別,主要是覆蓋的東西挺多的。 然後就是自訂資料, 介面顯示,主要是搭一個架子, 想擴充的,美化效果的,可以自訂style
Time of Update: 2018-12-05
ios6之前在一個字串中如果也讓某個字型高亮或者特殊顯示(如: 關注[101]),需要用單獨一個的標籤進行顯示,或者利用CoreText進行字型繪繪製,非常麻煩;現在IOS6 中TextView,label,textField中新增了這樣的一個屬性NSAttributedString 只能應用IOS6@property(nonatomic,copy) NSAttributedString *attributedText NS_AVAILABLE_IOS(6_0); // default is
Time of Update: 2018-12-05
- (void)drawRect:(CGRect)rect{ // draw a box with rounded corners to fill the view - UIBezierPath *roundedRect = [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:5.0f]; [[UIColor colorWithWhite:0.8 alpha:0.5] setFill];
Time of Update: 2018-12-05
修改hosts 檔案內容:進入etc 檔案夾,找到hosts 檔案,把該檔案複製出來,修改完裡面的內容後,先把etc中的hosts 檔案刪除,然後在把修改後的檔案離線去可能需要管理員的密碼,你輸入你的登陸密碼就ok搞定了有兩種辦法來實現顯示 Mac 下的隱藏檔案:命令列方式和軟體方式。命令列方式:顯示/隱藏Mac隱藏檔案命令如下(注意其中的空格並且區分大小寫):顯示Mac隱藏檔案的命令:defaults write com.apple.finder AppleShowAllFiles
Time of Update: 2018-12-05
諸位,咱當電子工程師也是十餘年了,不算有出息,環顧四面,也沒有看見幾個有出息的!回顧工程師生涯,感慨萬千,願意講幾句掏心窩子的話,也算給咱們師弟師妹們提個醒,希望他們比咱們強!
Time of Update: 2018-12-05
上一篇日誌談到了位操作。 關於位操作符:(1)、~取反~0011 = 1100(2)、&位與0011 & 0110 = 0010(3)、|位或0011 | 0110 = 0111(4)、^異或0011 ^ 0110 = 0101 有兩道題關於位異或(^)運算的妙用:一、已知長度為2n+1的數組,數組中每個數都出現兩次,只有一個數x是單獨出現的。求出這個單獨出現的數x?首先,說個知識點:a ^ a = 0; 0 ^ x = x;所以,解法就是把數組所有的數做異或操作,a1^a2
Time of Update: 2018-12-05
1.將字典或者數組還原序列化為NSString. NSMutableDictionary *jsonDic = [NSMutableDictionary dictionary]; NSMutableDictionary *alert = [NSMutableDictionary dictionary]; NSMutableDictionary *aps = [NSMutableDictionary dictionary]; [alert setObject:@"a
Time of Update: 2018-12-05
昨天用JPA時遇到一個小問題,entitymanager是通過@PersistContext方法注入的,使用entitymanager查詢對象沒有問題,但進行持久化時就無法儲存資料到資料庫,程式也沒有拋出任何異常。瞎搗鼓了一天,總以為是persistence.xml檔案哪裡出問題,最後上網查資料,看到別人提到transaction-type中的JTA和RESOURCE_LOCAL的區別,才想到自己在調用persis()方法之前沒有添加@Transactional標籤。 現在問題解決了,衷心的感謝
Time of Update: 2018-12-05
1.js判斷PC瀏覽器<script type="text/javascript">var Sys = {};var ua = navigator.userAgent.toLowerCase();var s;(s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] :(s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] :(s = ua.match(/chrome\/([\d.]+)/)
Time of Update: 2018-12-05
根據使用者輸入的語言類型或者平台類型,自動產生對應的gitignore檔案。例如,輸入android,eclipse,點擊“Genernate”即可。得到gitignore檔案:# Generated by http://gitignore.io### Android #### built application files*.apk*.ap_# files for the dex VM*.dex# Java class files*.class# generated filesbin/gen/
Time of Update: 2018-12-05
package com.liao.intentservice;import java.util.Arrays;import android.content.Context;import android.content.res.Resources;import android.graphics.Canvas;import android.graphics.Color;import android.graphics.Paint;import
Time of Update: 2018-12-05
1.添加fcitx源(官方的源是舊版,不推薦使用) fcitx的ppa源,內含fcitx和fcitx-config,由wengxt搭建,使用命令 sudo gedit /etc/apt/sources.list,在sources.list檔案中尾部添加 deb http://ppa.launchpad.net/wengxt/fcitx-nightly/ubuntu maverick main 然後更新源sudo apt-get update(GPG公匙導入失敗解決:gpg
Time of Update: 2018-12-05
出現這種錯誤經常是因為我們粗心或者採取錯誤的方式給目錄設定許可權的時候。這個時候,使用普通帳號(非root)執行sudo時候,就會報題目中的錯誤。解決方式可參考如下:1、使用root登入系統,執行:chmod 0440 sudoerschmod 0440 /etc/sudoers.d/READMEchmod 0700 /var/lib/sudo2、上述command執行之後,sudo即可正常使用了。如果使用ping等命令時候可能會出現 ping: icmp open socket:
Time of Update: 2018-12-05
通常,在linux中使用ssh的時候,如果出現這個錯誤,建議首先去查看log。ubuntu的ssh的log記錄在/var/log/auth.loglog錯誤會類似於如下:Dec 22 09:43:31 x079-liongao sshd[14883]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@Dec 22 09:43:31 x079-liongao sshd[14883]: error: @
Time of Update: 2018-12-05
一、採用純js實現這個是左右選框公用畫面,SelectBox.jsp<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><script type="text/javascript" language="JavaScript">function allsel(n1, n2) {var selN1 = document.getElementById(n1);
Time of Update: 2018-12-05
二、採用Jquery實現<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><script type="text/javascript" language="JavaScript">//add$(function(){$("#add").click(function(){if($("#selectRights
Time of Update: 2018-12-05
當需要排序的集合或數組不是單純的數字型時,通常可以使用Comparator或Comparable,以簡單的方式實現對象排序或自訂排序。一、Comparator強行對某個對象collection進行整體排序的比較函數,可以將Comparator傳遞給Collections.sort或Arrays.sort。介面方法: /** * @return o1小於、等於或大於o2,分別返回負整數、零或正整數。 */ int compare(Object o1, Object
Time of Update: 2018-12-05
這是官方Google Earth穩定版本的軟體源軟體源描述: Official Google repo for Google Earth stable添加這個源以安裝和更新Google Earth,請開啟終端並按以下步驟進行:1.設定公開金鑰 :wget -q -O – https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -添加軟體源:sudo sh -c ‘echo “deb