Time of Update: 2018-12-08
Content Provider:一個組件,必須放在應用的主包或應用的子包之下;組件的配置需要在資訊清單檔中進行配置;content provider需要在application節點中進行配置;內容提供者在應用中的作用是對外共用資料(任意類型的資料)使用的,別的程式可以對資料進行CRUD,如通訊錄;如果採用檔案的方式對外共用資料,會因為檔案的類型不同而需要使用不同的api訪問方式導致訪問繁雜,而內容提供者提供了統一的api對資料進行操作;<provider android:name=".
Time of Update: 2018-12-08
解析XML檔案:在Android平台上可以使用SAX、DOM和Android附帶的pull解析器解析XML檔案;pull解析器提供了各種事件,使用parser.next()方法進入下一個元素並觸發相應事件,pull解析器產生的事件是一個數字,可以通過switch對感興趣的事件進行處理;通過paser.nextText()方法可以擷取下一個Text類型的節點的值;http://xmlpull.org/xmlpull-website/impls.shtml;讀取XMLXmlPullParser
Time of Update: 2018-12-08
SharedPreferences用於在開發軟體的時候提供軟體參數設定,其背後使用的是xml檔案存放資料,檔案儲存在/data/data/<package name>/shared_prefs目錄下;複製代碼 代碼如下: public void savePreferences(String name, Integer age) {-->> get SharedPreferences SharedPreferences preferences =
Time of Update: 2018-12-08
首先,建立一個用於顯示一個item的layout,名為item.xml複製代碼 代碼如下:<?xml version="1.0" encoding="utf-8"?><LinearLayout
Time of Update: 2018-12-08
首先看程式介面如下!1、布局檔案:複製代碼 代碼如下:<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"
Time of Update: 2018-12-08
TabWidget類似於Android 中查看電話薄的介面,通過多個標籤切換顯示不同內容。要實現這一效果,首先要瞭解TabHost,它是一個用來存放多個Tab標籤的容器。每一個Tab都可以對應自己的布局,比如,電話薄中的Tab布局就是一個List的線性布局了。 要使用TabHost,首先需要通過getTabHost方法來擷取TabHost的對象,然後通過addTab方法來向TabHost中添加
Time of Update: 2018-12-08
我們的應用或多或少都會從網路擷取圖片資料然後進行顯示,下面就將實現一個這樣的例子,擷取網路中的圖片!首先:我們來看一下介面中有三個控制項,一個EditText,一個Button,一個ImageView1、下面是具體布局檔案<EditText android:id="@+id/picturepagh" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@strin
Time of Update: 2018-12-08
複製代碼 代碼如下:<SPAN style="FONT-SIZE: 18px">private void alertScreenDialog() { DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); String optStr = "手機螢幕解析度為: "+dm.widthPixels+" x "+dm.heightPixels;
Time of Update: 2018-12-08
複製代碼 代碼如下:package com.demos; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class GetScreenActivity extends Activity { private Button
Time of Update: 2018-12-08
提示:org.xmlpull.v1.XmlPullParserException: PI must not start with xml (position:unknown @1:5 in java.io.InputStreamReader@47ec2770)org.xml.sax.SAXParseException: PI must not start with xml (position:unknown xm@3:5 in
Time of Update: 2018-12-08
先把來源貼上http://zrgiu.com/blog/2011/01/making-your-android-app-look-better/http://www.dibbus.com/2011/02/gradient-buttons-for-android/http://www.dibbus.com/2011/08/even-more-gradient-buttons-for-android/然後再讓大家看看效果,這些都是xml布局檔案實現的,一張圖片都未曾使用。順便貼出幾個布局檔案給大家看
Time of Update: 2018-12-08
複製代碼 代碼如下:<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"
Time of Update: 2018-12-08
1. 對圖片本身進行操作盡量不要使用 setImageBitmap、setImageResource、 BitmapFactory.decodeResource 來設定一張大圖,因為這些方法在完成 decode 後,最終都是通過 Java 層的 createBitmap 來完成的,需要消耗更多記憶體。因此,改用先通過 BitmapFactory.decodeStream 方法,建立出一個 bitmap,再將其設為 ImageView 的 source,decodeStream
Time of Update: 2018-12-08
經查是因為本地文檔中的網頁有如下js代碼會連網載入資訊,將其注釋掉後就好了複製代碼 代碼如下:<script src="http://www.google.com/jsapi" type="text/javascript"></script>用一下java代碼就可以批量注釋複製代碼 代碼如下:package cn.sd.fxd.android;/* * 去掉Android文檔中需要連網的javascript代碼 */import
Time of Update: 2018-12-08
複製代碼 代碼如下:import java.io.BufferedReader; import java.io.InputStreamReader; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.
Time of Update: 2018-12-08
1. 圖片放縮複製代碼 代碼如下:// zoom 放縮 public static Bitmap zoomBitmap(Bitmap bitmap, int w, int h) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); Matrix matrix = new Matrix(); float scaleWidth = w / (float) width;
Time of Update: 2018-12-08
1、為什麼需要寫一個通用xml解析方法。 當需要解析不同的xml節點。你有可能是在xml解析的時候匹配不同節點並且節點名都是寫死的,這樣的話你解析不同的節點就需要不同的解析方法。當然這種方式是最簡單也是最笨的方法。為了減少代碼把代碼寫得更有品質那麼你就需要考慮設計一個通用的xml解析方法。2、解析思路。
Time of Update: 2018-12-08
在最近寫的一個Android中需要請求web伺服器中的資料,有一個登入Activity,登入後會到MainActivity,這中間登入和MainActivity都需要請求php的jsonapi,所以要在網路請求中保持session的,研究了好半天才搞定。其實sesion在瀏覽器和web伺服器直接是通過一個叫做name為sessionid的cookie來傳遞的,所以只要在每次資料請求時保持sessionid是同一個不變就可以用到web的session了,做法是第一次資料請求時就擷取sessioni
Time of Update: 2018-12-08
1、特效按鈕的進展 之前的思路:css設定div的樣式,在js中實現div對事件的響應,並改變div的樣式,以實現動畫效果。 1:以動畫的形式 複製代碼 代碼如下:var bb = document.getElementById("element"); bb.onclick=function(){ bb.className="list-item-download-inner2";//改變類名,改變CSS樣式 var t = setTimeout("init()",500);
Time of Update: 2018-12-08
相關文章 Android 4.0 無法接收開機廣播的問題 在設定檔AndroidManifest.xml中向系統註冊receiver,子節點 intent-filter 表示接收android.intent.action.BOOT_COMPLETED訊息 複製代碼 代碼如下:<receiver android:name="com.ray.ray.receiver.BootCompletedReceiver" > <intent-filter> <action