Time of Update: 2013-12-10
在前文Android定位功能(一)中,已經大致介紹了一下在Android平台中,和定位功能相關的類,並舉例擷取了位置資訊。但是前文是基於Criteria定製了一個標準,通過getBestProvider()方法由Android系統自動擷取最符合Criteria的LocationProvider,從而實現了定位功能。這樣的做法能最大限度的保證定位功能的可實現性,但是卻無法保證擷取到的位置資訊有最大的準確度。因為除了GPS外,其他定位方式都或多或少存在著位置位移。 在實現GPS定位前,先瞭解一下G
Time of Update: 2013-12-10
系統內建的Theme:--------------------------------------------------------------------------------android以及為我們定義好了一些theme,需要是我們直接可以拿來使用。常用的Theme通常如下: android:theme="@android:style/Theme.Dialog"將一個activity顯示為對話方塊模式 android:theme=&qu
Time of Update: 2013-12-10
public class MainActivity extends Activity {private GridView gridView;private int res[] = new int[] {R.drawable.an01,R.drawable.an02, R.drawable.an03, R.drawable.an01, R.drawable.an02,R.drawable.an03,R.drawable.an01,R.drawable.an02, R.drawable.an03,
Time of Update: 2013-12-10
我們只需要重寫子viewpager 就可以很好的解決這個問題了 /** * ChanpinViewPager.java * com.stg.ln.utils.ui * * Function: TODO * * ver date
Time of Update: 2013-12-10
,返回和菜單鍵是可以直接重寫onKeyDown(int keyCode, KeyEvent event) 方法監聽:@Overridepublic boolean onKeyDown(int keyCode, KeyEvent event) {if (keyCode == KeyEvent.KEYCODE_BACK) { // 監控/攔截/屏蔽返回鍵//do something} else if (keyCode == KeyEvent.KEYCODE_MENU) {//do
Time of Update: 2013-12-10
URL的openConnection方法將返回一個URLConnection,該對象表示應用程式和URL之間的通訊串連。程式可以通過它的執行個體向該URL發送請求,讀取URL引用的資源。下面通過一個簡單樣本來示範:Activity: package com.home.urlconnection; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection;
Time of Update: 2013-12-10
下面是一個簡單的json 解析的demo,廢話不多說,直接上代碼 package com.sky.gallery;import java.io.ByteArrayOutputStream;import java.io.DataInputStream;import java.io.IOException;import java.io.InputStream;import
Time of Update: 2013-12-10
網路操作是進行網路通訊的安卓程式必不可少的一個重要部分,Android平台有三種網路介面可以使用,他們分別是:java.net.*(標準Java介面)、Org.apache HttpComponents介面和Android.net.*(Android網路介面)。當然還可以使用瀏覽器webkit來進行網路訪問等。其中,前兩個介面可以用來進行http、socket通訊,後一個介面主要是用來判斷安卓裝置網路連接狀況的。所以,本節重點說一下前兩個介面。 1、java.
Time of Update: 2013-12-10
方法一 Timer與TimerTask(Java實現) [java] view plaincopyprint? public class timerTask extends Activity{ private int recLen = 11; private TextView txtView; Timer timer =
Time of Update: 2013-12-10
有人說聲明 Private Destructor, 這對象只能在 stack 上建立,不能在Heap上建立, 其實錯了, 這樣的程式編譯都過不了. 那為何會有 Private Destructor, 因為程式是這樣寫的 ------------------------------------class Base {public: Base();protected: virtual ~Base();
Time of Update: 2013-12-10
package com.comnvi.camera;import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import java.text.SimpleDateFormat;import java.util.Date;import java.util.concurrent.ExecutorService;import java.util.concurrent.Executors;import
Time of Update: 2013-12-10
很多時候,android提供的組件並不能滿足我們的需求,於是我們不得不按需求開發自訂控制項。Step 1. 寫好自訂控制項的內部布局檔案。 <?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
Time of Update: 2013-12-10
public class ResizeLayout extends FrameLayout { private OnkeyboardShowListener mChangedListener; private boolean misKeyboardshow = false; private RRSharedPreferences preferences; private int keyboardHeight =
Time of Update: 2013-12-10
前幾天做一個小應用,需要用到在service中調用Activity, 但是發現總是出現ANR,百度了下,發現各種說法,不過經過嘗試,發現問題不大,只需要加一句代碼就足夠了,代碼如下: public class XXXService extends Service { public void onCreate() { super.onCreate(); //撥打到電話 Intent call = new Intent(&
Time of Update: 2013-12-10
private void toExecuteSave(){ Intent intent = new Intent(Intent.ACTION_INSERT); intent.setType("vnd.android.cursor.dir/person"); intent.setType("vnd.android.cursor.dir/contact");
Time of Update: 2013-12-10
1 xml <?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"
Time of Update: 2013-12-10
筆者最近開始淪陷於android,從開始入門到現在已經快半個月的時間,於是便寫一個較綜合,用到了資料庫,多線程操作,以及時鐘的添加和停止消除,activity之間的動畫轉換等,適用於初學者學以致用的小遊戲來鞏固自己的知識,有需要的讀者可以去我的資產庫中下載源碼。 以下是主遊戲程式的部分代碼,帶有筆者的豐富注釋: package com.example.pingping_game1;import java.util.HashMap;import
Time of Update: 2013-12-10
ImageView沒有邊角圓化的設定,但是可以通過代碼設定實現。一個國外的碼農寫的方法。 package com.example.roundrectshader; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import
Time of Update: 2013-12-10
package cc.testservice2;import android.app.Activity;import android.content.ComponentName;import android.content.Intent;import android.content.ServiceConnection;import android.os.Bundle;import android.os.IBinder;import android.view.View;import
Time of Update: 2013-12-10
主介面上是兩個EditText和一個按鈕。用於輸入兩個數字參數。calcute.xml: <?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"