Time of Update: 2018-12-04
android中ListView使用最為頻繁,但是同時出現錯誤也是最多的,下面就總結一下我在開發中遇到的問題,問題一:在自訂添加adapter中添加button,或是checkBox時無法同時響應setOnItemClickListener事件中的item click 事件和控制項本身點擊事件item 原布局檔案;<?xml version="1.0" encoding="utf-8"?><RelativeLayout
Time of Update: 2018-12-04
android:drawSelectorOnTop="true" 點擊某一條記錄,顏色會顯示在最上面,記錄上的文字被遮住,所以點擊文字不放,文字就看不到android:drawSelectorOnTop="false"
Time of Update: 2018-12-04
先看;詳細看代碼;package com.taskmanage.file;import java.util.ArrayList;import java.util.Collections;import java.util.HashMap;import java.util.Iterator;import java.util.List;import java.util.Map;import android.app.Activity;import
Time of Update: 2018-12-04
先說說原理,大家知道,android可以對資料庫進行監控。但是個人感覺這個監控不給力,無論怎麼實現監控,最後返回的結果是資料庫是否改變,沒有告訴我們資料庫的那條資料進行了改變或者是刪除,添加,並不能解決大多數需求。當初我遇到這樣的問題我也很痛苦,無論怎麼早資料都沒找到自己想要的,而網上大多數資料只是告訴你怎麼監控資料庫,但沒有告訴你怎麼擷取具體的資料改變。往往成功是逆境裡逼出來的,我去尋找英文API,發現ContactsContract.RawContacts類中VERSION欄位的說明,原文如
Time of Update: 2018-12-04
最近總結了一下Android中對圖片處理方法,具體如下:/** * 圖片反轉 * @param img * @return */public Bitmap toturn(Bitmap img){Matrix matrix = new Matrix();matrix.postRotate(90); /*翻轉90度*/int width = bitmap.getWidth();int height =bitmap.getHeight();img = Bitmap.createBitmap(img,
Time of Update: 2018-12-04
android 中定時操作需要依靠AlarmManager類來完成該功能:下面舉例分析:DateSetActivity:package com.hello.project;import java.util.Calendar;import android.app.Activity;import android.app.AlarmManager;import android.app.DatePickerDialog;import android.app.Dialog;import
Time of Update: 2018-12-04
Android調用打電話,發簡訊功能可分為直接調用和間接調用,通過設定intent屬性即可實現:直接調用,不經過使用者確認://電話 Intent intent = new Intent( Intent.ACTION_CALL, Uri.parse("tel:10086")); startActivity(intent); //簡訊String smsContent = "ye";
Time of Update: 2018-12-04
建立SysCamera類package com.recorder.video;import java.io.File;import java.text.SimpleDateFormat;import java.util.Date;import com.recoder.start.MyRecorderActivity;import com.recoder.start.R;import android.app.Activity;import
Time of Update: 2018-12-04
最近項目裡使用到了android中重力感應使用,現分享給大家。重力感應座標是相對於裝置而言,而不是空間座標,代碼如下;package com.pioneersoft.temp;import android.app.Activity;import android.content.Context;import android.content.Intent;import android.hardware.Sensor;import
Time of Update: 2018-12-04
有時候我們可能需要將兩張後多張圖片疊加到一起使其成為一張合成圖片下面是我整理的資料,方便日後複習使用public Bitmap diejia(Bitmap b){ if(!b.isMutable()){//設定圖片為背景為透明b = b.copy(Bitmap.Config.RGB_565, true);//}Canvas canvas = new Canvas(b);Bitmap lock=BitmapFactory.decodeResource(getResources(),
Time of Update: 2018-12-04
Android 中語音朗讀比較簡單,下面是一個小例子;package com.recorder.audio;import java.util.Locale;import android.app.Activity;import android.os.Bundle;import android.speech.tts.TextToSpeech;import android.util.Log;import android.widget.Button;public class TextSpeech
Time of Update: 2018-12-04
擷取mac地址:public String getLocalMacAddress() { WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); WifiInfo info = wifi.getConnectionInfo(); return info.getMacAddress(); } 或者:private String
Time of Update: 2018-12-04
在android中為了安全性起見,對於一些系統的相關操作定義了很多許可權,比如打電話,簡訊,檔案寫入等等。為了確保應用程式安全,穩定性,我們可以自訂一些許可權機制來阻止其他應用程式對本應用程式的相關操作。下面舉個例子;在A項目的AndroidManifest.xml配置如下;<?xml version="1.0" encoding="utf-8"?><manifest
Time of Update: 2018-12-04
這次主要是使用android系統內建控制項ViewFlipper 結合手勢和動畫實現滾動效果,類似於軟體協助效果:主要代碼:package com.pioneersoft.systemhelp;import java.util.HashMap;import org.apache.http.impl.client.TunnelRefusedException;import android.app.Activity;import android.content.Context;import
Time of Update: 2018-12-04
Android中擷取系統時間有多種方法,可分為Java中Calendar類擷取,java.util.date類實現,還有android中Time實現現總結如下:方法一;void getTime1(){ long time=System.currentTimeMillis();//long now = android.os.SystemClock.uptimeMillis(); SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-
Time of Update: 2018-12-04
本文截選自《Android開發權威指南》 Android
Time of Update: 2018-12-04
總結一下,android中設定壁紙幾種方法方法一: 擷取WallpaperManager執行個體 private void set_mytheme(int resid){ WallpaperManager wallpaperManager = WallpaperManager.getInstance(this); // Resources res = getResources(); try {
Time of Update: 2018-12-04
程式想告訴Android系統自己能夠響應和處理哪些Intent,那麼就需要用到IntentFilter對象,IntentFilter對象負責過濾掉組件能夠處理的Intent請求,隱式Intent(Explicit Intents)和Intent Filter(Implicit
Time of Update: 2018-12-04
在Android中不支援直接載入gif格式的圖片,只能通過輔助類Movie實現,具體方法如下;public class DrawMusicNote extends View {private Movie mMovie;private long mMovieStart;//Set to false to use decodeByteArrayprivate static final boolean DECODE_STREAM = true;public DrawMusicNote(Context
Time of Update: 2018-12-04
擷取狀態列和標題列的高度擷取狀態列高度: getWindowVisibleDisplayFrame方法可以擷取到程式顯示的地區,包括標題列,但不包括狀態列。 於是,我們就可以算出狀態列的高度了。Rect frame = new Rect(); getWindow().getDecorView().getWindowVisibleDisplayFrame(frame); int statusBarHeight =