Time of Update: 2018-12-06
轉載自:http://www.cnblogs.com/onlylittlegod/archive/2011/05/15/2046652.html最近學習了一下Android裡面的Service的應用,在BindService部分小卡了一下,主要是開始沒有徹底理解為什麼要這麼實現。BindService和Started Service都是Service,有什麼地方不一樣呢:1. Started
Time of Update: 2018-12-06
1:AsyncTask是多線程嗎?答:是。2:AsyncTask與Handler相比,誰更輕量級?答:通過看源碼,發現AsyncTask實際上就是一個線程池,而網上的說法是AsyncTask比handler要輕量級,顯然上不準確的,只能這樣說,AsyncTask在代碼上比handler要輕量層級,而實際上要比handler更耗資源,因為AsyncTask底層是一個線程池!而Handler僅僅就是發送了一個訊息佇列,連線程都沒有開。
Time of Update: 2018-12-06
首先繼承SimpleAdapterpackage meetweb.net.util;import java.util.List;import java.util.Map;import android.content.Context;import android.graphics.Color;import android.view.View;import android.view.ViewGroup;import android.widget.SimpleAdapter;public class
Time of Update: 2018-12-06
Android 實現TextView中文字連結的方式 Android 的實現TextView中文字連結的方式有很多種。 總結起來大概有4種: 1.當文字中出現URL、E-mail、電話號碼等的時候,可以將TextView的android:autoLink屬性設定為相應的的值,如 果是所有的類型都出來就是android:autoLink="all"。當然也可以在java代碼裡 做,textView01.setAutoLinkMask(Linkify.ALL); 2.將要處理的文字寫到一個資源檔,
Time of Update: 2018-12-06
一:不同的layout Android手機螢幕大小不一,有480x320, 640x360, 800x480,854x480.怎樣才能讓App自動適應不同的螢幕呢? 其實很簡單,只需要在res目錄下建立不同的layout檔案夾,比如layout-640x360,layout-800x480,所有的layout檔案在編譯之後都會寫入R.java裡,而系統會根據螢幕的大小自己選擇合適的layout進行使用。
Time of Update: 2018-12-06
This is going to be a quick hit blog post about the Android"ViewHolder" pattern. This is a pattern that many people seem to be atleast vaguely familiar with, but not very many actually use (based onopen source Android applications and examples/books,
Time of Update: 2018-12-06
Android高手進階教程(四)之----Android 中自訂屬性(attr.xml,TypedArray)的使用!收藏 今天我們的教程是根據前面一節擴充進行的,如果你沒有看,請點擊 Android高手進階教程(三)
Time of Update: 2018-12-06
文章目錄 什麼是URI?ContentResolver 介紹說明製作ContentResolver執行個體總結說明
Time of Update: 2018-12-06
1.編譯前的準備工作 請確認以下包的版本是否OK: 1.1 gcc4.4,而不是gcc4.6,如果是4.6,需要安裝gcc4.4,命令如下: sudo apt-get install gcc-4.4 sudo apt-get install g++-4.4 cd /usr/bin ls -l gcc* sudo mv gcc gcc.bak sudo ln -s gcc-4.4 gcc ls -l g++* sudo mv g++
Time of Update: 2018-12-06
http://www.android-study.com/jichuzhishi/154.html1.第一種方法:使用setOnKeyListener(),不過這種方式只能監聽硬鍵盤事件。1 edittext.setOnKeyListener(new View.OnKeyListener() {2 @Override3 public boolean onKey(View v, int keyCode, KeyEvent event) {4
Time of Update: 2018-12-06
轉載:http://android-zhang.iteye.com/blog/1562791一、
Time of Update: 2018-12-06
轉載 :http://www.cxy.me/doc/5558.htm架構iPhoneCocoaFoundation(Mac OS X共通)UIKitAndroidJavaSDKAndroidFrameworkMVCiPhoneModel任意ViewUIView的父類InterfaceBuiler
Time of Update: 2018-12-06
根據Activity的聲明周期 方法1 我們知道Android的視窗類別提供了曆史棧,我們可以通過stack的原理來巧妙的實現,這裡我們在A視窗開啟B視窗時在Intent中直接加入標誌 Intent.FLAG_ACTIVITY_CLEAR_TOP,這樣開啟B時將會清除該進程空間的所有Activity。 在A視窗中使用下面的代碼調用B視窗 Java代碼 Intent intent = new Intent(); intent.setClass(Android123.this,
Time of Update: 2018-12-06
表格版面配置包含一系列的 TableRow對象,用於定義行(實際上你也可以使用其它子物件,將在後面進行解釋)。表格版面配置不為它的行、列和儲存格顯示表格線。每個行可以包含0個以上(包括0)的儲存格; 每個儲存格可以設定一個View對象.與行包含很多儲存格一樣, 表格包含很多列。表格的儲存格可以為空白.儲存格可以象 HTML 那樣跨列。 列的寬度由該列所有行中最寬的一個儲存格決定.不過表格版面配置可以通過 setColumnShrinkable() 方法或者
Time of Update: 2018-12-06
背景知識:當Android啟動時,會發出一個系統廣播,內容為ACTION_BOOT_COMPLETED,它的字符串常量表示為 android.intent.action.BOOT_COMPLETED。只要在程式中“捕捉”到這個訊息,再啟動之即可。記住,Android架構說:Don''t call me, I''ll call you
Time of Update: 2018-12-06
在android中,經常要用到協助、about、關於作者等的提示頁面。類似這樣的頁面:這樣的頁面,我們可以通過AlertDialog對話方塊來設計。設計一個AboutDialog類繼承於AlertDialogpublic class AboutDialog extends AlertDialog { public AboutDialog(Context context) { super(context); final View view =
Time of Update: 2018-12-06
Demo介紹:首頁是一個GridView載入圖片,豎屏時顯示3列圖片,橫屏時顯示4列圖片;並且對圖片進行大小限制和加灰色邊框處理。點擊某一張圖片,會連結到Gallery頁面,由於Android內建的Gallery控制項滑動效果很不好(滑動一次會載入好多張圖片),這裡對Gallery進行了擴充,滑動一次只載入一張圖片。Demo效果如下: 1、首頁Activity頁面,GridViewActivity.java介紹:public class GridViewActivity extends
Time of Update: 2018-12-06
今天匯入一個Android的例子程式,出現了Unable to resolve target 'android-8'的錯誤。剛開始以為是沒匯入包或者是phoneGap沒配置好。可是折騰了好久還是報錯。最後google之後才發現原來是ADK版本不同。ADK版本:---API Level對應關係(注意高版本不一定是相容低版本的)android2.3.4---10 android2.3.1---9===Gingerbread android2.2---8===Froyo
Time of Update: 2018-12-06
1)如何獲得MediaPlayer執行個體:可以使用直接new的方式:MediaPlayer mp = new MediaPlayer();也可以使用create的方式,如:MediaPlayer mp = MediaPlayer.create(this, R.raw.test);//這時就不用調用setDataSource了 2) 如何設定要播放的檔案:MediaPlayer要播放的檔案主要包括3個來源:a.
Time of Update: 2018-12-06
在Android中,用string-array是一種簡單的提取XML資源檔資料的方法。例子如下:把相應的資料放到values檔案夾的arrays.xml檔案裡<?xml version="1.0" encoding="utf-8"?><resources> <string-array name="city"> <item>廈門市</item> <item>福州市</item>