Time of Update: 2013-12-11
在開發過程中解析xml中的資料有上萬條之多,發現在想sqlite中插入的時候非常耗時,原因是沒有使用事務,預設是每插入一次使用一次事務,這樣如果插入1w條資料,就要開啟1w次事務,非常耗時,所以我們可以通過手動開啟和關閉的方式控制事務。在自己的繼承了SQLiteOpenHelper的子類中加入插入方法[html] /** * databasename 是表名 *
Time of Update: 2013-12-11
在AndroidManifest.xml的Activity配置中加入 android:screenOrientation=”landscape”屬性(landscape是橫向,portrait是縱向)。比如<activity android:name=".ContactsManagerActivity" &
Time of Update: 2013-12-11
找到兩種密碼編譯演算法,一種MD5加密,適用於密碼加密,因為這種演算法無法復原;還有一種是RSA加密,這種加密是可逆的: 一、MD5加密 import java.security.MessageDigest; public class MD5 { private final static String[]
Time of Update: 2013-12-11
Android的對話方塊有兩種:PopupWindow和AlertDialog。它們的不同點在於:AlertDialog的位置固定,而PopupWindow的位置可以隨意AlertDialog是非阻塞線程的,而PopupWindow是阻塞線程的PopupWindow的位置按照有無位移分,可以分為位移和無位移兩種;按照參照物的不同,可以分為相對於某個控制項(Anchor錨)和相對於父控制項。具體如下showAsDropDown(View
Time of Update: 2013-12-11
前面例子介紹了檢測,讀寫NFC TAG開發的一般步驟,本例針對常用的Mifare Tag 具體說明。Mifare Tag 可以有1K ,2K, 4K,其記憶體分區大同小異,給出了1K位元組容量的Tag的記憶體分布: 資料分為16個區(Sector) ,每個區有4個塊(Block) ,每個塊可以存放16位元組的資料,其大小為16 X 4 X 16 =1024 bytes每個區最後一個塊稱為Trailer ,主要用來存放讀寫該區Block資料的Key ,可以有A,B兩個Key,每個Key
Time of Update: 2013-12-11
Activity的啟動模式可以通過AndroidManifest.xml檔案中的<activity>元素的屬性來指定,一共有4中模式: <activity android:name="ActivityMain"
Time of Update: 2013-12-11
簡而言之,TCP與UDP之間的區別在於,TCP傳輸資料安全但速度慢,UDP傳輸容易丟包但速度快。一般銀行要採取TP協議,IM要使用UDP協議。首先我們來看一下什麼是TCP和UDP。什麼是TCP?TCP:Transmission Control Protocol 傳輸控制通訊協定TCP是一種連線導向(串連導向)的、可靠的、基於位元組流的運輸層(Transport layer)通訊協定,由IETF的RFC
Time of Update: 2013-12-11
一,橫豎屏切換時不重新載入資料,只需在menifest中加入:android:configChanges="keyboardHidden|orientation"二,橫豎屏切換時重新載入資料,程式會程式進入onCreate,因此需要對資料進行儲存以備後用。***方法一: @Override public Object onRetainNonConfigurationInstance()
Time of Update: 2013-12-11
1. 繼承關係java.lang.Object |____android.app.FragmentManager2.
Time of Update: 2013-12-11
最近在做一個鬧鐘的項目,當鬧鐘響起的時候需要用到自動解鎖和點亮螢幕,因此記錄一下解螢幕鎖與點亮螢幕的代碼:KeyguardManager km= (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); //得到鍵盤鎖管理器對象KeyguardLock kl = km.newKeyguardLock("unLock"); //參數是LogCat裡用的Tagkl.disableKeyguard();
Time of Update: 2013-12-11
有時會發現由於記憶體不夠而導致錯誤,大都來源於Image太大造成的。下面給出一個簡單有效方法:BitmapFactory.Options opts = new BitmapFactory.Options();opts.inSampleSize = 4;Bitmap bitmap = BitmapFactory.decodeFile(imageFile,
Time of Update: 2013-12-11
var old:float; var news:float; var h:float; var d:float; var v:float; var a:float; function Start(){ h=0; d=0; old=Input.acceleration.z; news=0;
Time of Update: 2013-12-11
package ahu.edu; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import
Time of Update: 2013-12-11
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo)當View對象相關的操作功能表顯示的時候,系統會調用該方法。跟onCreateOptionMenu(Menu,
Time of Update: 2013-12-11
package youbanwang.co.cc; import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.os.Handler;import android.view.animation.Animation;import android.view.animation.AnimationUtils;public class Splash
Time of Update: 2013-12-11
最近研究了一下Contacts源碼,仿照上面自己寫了一個TabHostTest程式,現整理如下:main.xml布局檔案:[html]<?xml version="1.0" encoding="utf-8"?> <TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:
Time of Update: 2013-12-11
首先設定只能輸入數字:[html] <EditText android:id="@+id/edit_digit_input" android:layout_width="wrap_content"
Time of Update: 2013-12-11
此課程系列較短,都是對Android很基礎內容的講解,而且年代有點久遠,貌似視頻中使用的平台仍然是Android2.1,因此,如果有更高需求的話,可以參閱SDK文檔,其中有更為詳述的表示。不過,由於時間較短,每節課才23分鐘左右,所以即使作為練習聽力也不錯,而且還可以回顧一些Andriod基本知識,作為查缺補漏的工具,可以試聽。下面是上課筆記。第一節:介紹Android基本的生態環境,發展曆史,以及基本組件,Activity,broadcast receiver,Service,Content
Time of Update: 2013-12-11
通常情況下,一個activity可能包含一個或多個fragment,它們協同工作,組成一個連貫的UI介面。在這種情況下,多個fragments之間的通訊顯得就很重要了。舉個例子,一個activity包含左右兩個fragment,左側的fragment包含了一個列表(比如新聞題目列表),當點擊每個新聞題目的時候,右側的fragment就會顯示這條新聞的詳盡資訊。下面展示如何進行操作。工程目錄:Fragment1在整個activity的左側,Fragment2在右側。1.fragment
Time of Update: 2013-12-11
1. <ImageView 2. android:id="@+id/imgView" 3. android:layout_width="fill_parent" 4. android:layout_height="fill_