Time of Update: 2013-12-10
json資料格式解析我自己分為兩種;一種是普通的,一種是帶有數組形式的; 普通形式的:伺服器端返回的json資料格式如下:{"userbean":{"Uid":"100196","Showname":"\u75af\u72c2\u7684\u7334\u5b50","Avtar":null,"State":1}}分析代碼如下:// TODO
Time of Update: 2013-12-10
做移動互連網就不太可能不碰手機端的開發。上周為了項目需要,俺也挽袖子掄胳膊開始寫起了android程式,還好有java基礎,倒也上手快,寫了幾個小程式,主要都是關於定位方面的。網上也搜得到一些相關的文章和教程,但給出的例子效果不太好,而且感覺只有其表,卻不明其理。因此寫出此文,分享一些我的經驗。雖然是以android為主,但是我想對其它平台的開發也應該有些協助。這篇文章側重於制定一個合理的定位方案。手機定位的方式先科普一些基礎知識吧。最簡單的手機定位方式當然是通過GPS模組(現在大部分的智能機應
Time of Update: 2013-12-10
LinearLayout和RelativeLayout共有屬性:java代碼中通過btn1關聯次控制項android:id="@+id/btn1"控制項寬度android:layout_width="80px" //"80dip"或"80dp"android:layout_width =“wrap_content”android:layout_width =
Time of Update: 2013-12-10
首先是主要代碼 的實現 ,去調用 各個xml 設定檔:MainActivity: public class MainActivity extends Activity {private ImageView imageView;@Overrideprotected void onCreate(Bundle savedInstanceState)
Time of Update: 2013-12-10
–Bitmap代表這一張位元影像,BitmapDrawable裡封裝的圖片就是一個Bitmap對象。如果要將Bitmap對象封裝成BitmapDrawable對象只需要用構造方法即可。//講bitmap對象封裝成BitmapDrawable對象BitmapDrawable drawable = new BitmapDrawable(bitmap);//將BitmapDrawable對象轉換為bitmapBitmap bitmap =
Time of Update: 2013-12-10
使用SharedPreference時,資料的儲存必須使用commit()方法,否則資料不會儲存;資料會儲存在DDMS的包目錄下的shared_prefs下:Activity代碼 public class ContentProviderActivity extends Activity { /** Called when the activity is first created. */ private static final String FILENAME =
Time of Update: 2013-12-10
1.sharedpreference,儲存簡單的資訊,比如使用者名稱,密碼package com.google.datastore.sharep;import android.app.Activity;import android.content.Context;import android.content.SharedPreferences;import android.os.Bundle;import android.view.View;import
Time of Update: 2013-12-10
Looper對象,由它來管理此線程裡的MessageQueue(訊息佇列)。 2)Handler: 你可以構造Handler對象來與Looper溝通,以便push新訊息到MessageQueue裡;或者接收Looper從Message Queue取出)所送來的訊息。 3) Message Queue(訊息佇列):用來存放線程放入的訊息。 4)線程:UIthread 通常就是main thread,而Android啟動程式時會替它建立一個MessageQueue。 67.
Time of Update: 2013-12-10
Activity中有一個名稱叫onCreate的方法。該方法是在Activity建立時被系統調用,是一個Activity生命週期的開始。可是有一點容易被忽視,就是onCreate方法的參數saveInsanceState。一般的程式開發中,很少用到這個參數。 onCreate方法的完整定義如下: public void
Time of Update: 2013-12-10
代碼如下: Bitmap bitmap = mWebView.getFavicon(); Drawable drawable = new BitmapDrawable(bitmap); // edit.setCompoundDrawables(drawable, null, null, null); drawable =
Time of Update: 2013-12-10
//在按鈕點擊事件裡處理 bt_search.setOnClickListener(new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub&
Time of Update: 2013-12-10
首先,我就是用很容易理解的方法去實現這個功能。在伺服器端,做一個index.php檔案,用來讀取MySQL資料庫的資訊:index.php:<?php$link = mysql_connect("localhost", "root", "123456"); mysql_query("SET NAMES
Time of Update: 2013-12-10
在看Oplayer的時候看見滑動字母來實現listView的內容搜尋,所以就把裡面的核心的函數扣除來做了一個demo,分為兩部分一個是布局,另一個就是代碼了,具體的如下: 布局: [html] <?xml version="1.0" encoding="utf-8"?> <LinearLayout
Time of Update: 2013-12-10
添加案頭捷徑,非常簡單,只需三步: 1、建立一個添加捷徑的Intent,該Intent的Action為com.android.launcher.action.INSTALL_SHORTCUT。 2、通過為該Intent添加Extra屬性來設定捷徑的標題、表徵圖及捷徑對應啟動的程式。 3、調用sendBroadcast()方法發送廣播即可添加捷徑。 下面用一個簡單樣本來示範,在該應用程式中,只給出了添加案頭捷徑的內容,程式的具體應用無須給出,第一次安裝該程式
Time of Update: 2013-12-10
首先得Activity必須實現OnGestureListener介面,該介面提供了關於手勢操作的一些方法,onDown方法:onDown是,一旦觸控螢幕按下,就馬上產生onDown事件public boolean onDown(MotionEvent e) {return false;}onFling方法:當手在螢幕上滑動但手未離開螢幕時觸發MotionEvent e1 手開始觸碰螢幕的位置的MotionEvent對象MotionEvent e2
Time of Update: 2013-12-10
1、管理Fragment要在activity中管理fragment,需要使用FragmentManager. 通過調用activity的getFragmentManager()取得它的執行個體.•可以通過FragmentManager做一些事情, 包括: 使用findFragmentById()(用於在activity
Time of Update: 2013-12-10
在做一個小練習的時候,又遇到了Adapter,才發現以前沒有對它進行過記錄現在介紹一下:其實Adapter就是資料和視圖之間的橋樑,資料在adapter中做處理,然後顯示到ListView上面Adapter有很多種,有ArrayAdapter<T>, BaseAdapter, CursorAdapter, HeaderViewListAdapter, ListAdapter,ResourceCursorAdapter, SimpleAdapter,
Time of Update: 2013-12-10
不管你多麼仔細,程式總是會出錯,下面方法是個全域的異常捕獲方法!希望對大家有協助!1.用的時候,需要在applicaion裡面調用,代碼如下:CrashHandler crashHandler = CrashHandler.getInstance(); crashHandler.init(this);2. 下面是主要的功能類:package
Time of Update: 2013-12-10
Intent是什麼呢?來看Android官網上的定義:An intent is an abstractdescription of an operation to be performed. It can be used with startActivity tolaunch an Activity, broadcastIntent tosend it to any interestedBroadcastReceiver components,and startService(Intent)
Time of Update: 2013-12-10
今天看了一個Android的Training生命週期轉換的例子,頓覺得他的設計非常巧妙,我的分析如下: 1.在com.example.android.lifecycle包中有: