Time of Update: 2018-12-04
當父控制項中有子控制項的時候,並且父控制項和子空間都有事件處理(比如單擊事件)。這時,點擊子控制項,父控制項的單擊事件就無效了。如:比如一個LinearLayout裡面有一個子控制項TextView,但是TextView的大小沒有LinearLayout大①如果LinearLayout和TextView都設定了單擊事件,那麼點擊TextView地區的時候,觸發的是TextView的事件,點擊TextView以外的地區的時候,還是觸發的LinearLayout的事件。②如果LinearLayout
Time of Update: 2018-12-04
最近在項目中,遇到了application這個類,開始不知道有什麼用,經過學習後才知道它的用途也蠻大的,舉個例子,如果想在整個應用中使用全域變數,在java中一般是使用靜態變數,public類型;而在android中如果使用這樣的全域變數就不符合Android的架構架構,但是可以使用一種更優雅的方式就是使用Application context。 我們先看看一下這段說明: Base class for those who need to
Time of Update: 2018-12-04
今天想把drawable下的所有Drawable Resources 弄清楚,看到Clip Drawable 的時候,把以下原文檔裡的列子考到自己建的項目下clip.xml<?xml version="1.0" encoding="utf-8"?><clip
Time of Update: 2018-12-04
首先,定義layout檔案:custom_preference.xml<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent"
Time of Update: 2018-12-04
PULL方式除了可以使用 SAX和DOM解析XML檔案,也可以使用Android內建的Pull解析器解析XML檔案。 Pull解析器的運行方式與 SAX
Time of Update: 2018-12-04
項目用到ListView,由於要用到ImageView,圖片源不是在資源裡面的,沒法使用資源ID,因此無法直接使用SimpleAdapter,要自己寫一個Adapter。在使用ListView和Adapter需要注意以下幾點: 1. Adapter.getView() public View getView(int position, View convertView, ViewGroup parent){...} 這個方法就是用來獲得指定位置要顯示的View。官網解釋如下:Get a
Time of Update: 2018-12-04
CursorAdapter繼承於BaseAdapter是個虛類,它為cursor和ListView提供了串連的橋樑。 public abstract class CursorAdapter extends BaseAdapter直接子類只有ResourceCursorAdapterClass OverviewAdapter that exposes data from a Cursor to a ListView widget. The Cursor mu
Time of Update: 2018-12-04
我們都知道android中Adapter的作用就是ListView介面與資料之間的橋樑,當列表裡的每一項顯示到頁面時,都會調用Adapter的getView方法返回一個View。想過沒有? 在我們的列表有1000000項時會是什麼樣的?是不是會佔用極大的系統資源?我們先來看看下面的代碼:Java代碼:複製到剪貼簿 Java代碼public View getView(int position, View convertView, ViewGroup parent) { View item =
Time of Update: 2018-12-04
Google在Android 3.0SDK中推出的ViewPager控制項很大程度上滿足了開發人員開發頁面左右移動切換的功能,使用非常方便,參見:http://jameszhao84.iteye.com/blog/1344584。但是使用中發現,在刪除或者修改資料的時候,PagerAdapter無法像BaseAdapter那樣僅通過notifyDataSetChanged方法通知重新整理View。最基本的方法:針對於child
Time of Update: 2018-12-04
Android 遊戲引擎匯總1.AndEngine簡介:AndEngine 基於libGDX架構開發,使用OpenGL ES進行圖形繪製。同時繼承了BOX2D物理引擎,因此能實現一些較為複雜的物理效果。在Rokon停止更新以後,AndEngine 成為Android
Time of Update: 2018-12-04
文章目錄 1. View Animation(Tween Animation)2. Drawable Animation(Frame Animation)3. Property Animation3.1 Property Animation的工作方式3.2 ValueAnimator3.3 ObjectAnimator3.4 通過AnimationSet應用多個動畫3.5 TypeEvalutors3.6 TimeInterplator3.7
Time of Update: 2018-12-04
最近,遇到了一種定義尺寸的方法,類似於C裡面的宏定義一樣,其實以前已經見過了這種使用方式,今天有時間就記錄一下方便以後使用。下面來介紹一下:尺寸資源XML檔案的使用 下面還是通過一個執行個體來示範尺寸資源的用法。該執行個體在布局檔案中添加一個TextView和一個Button,分別使用尺寸資源檔來定義它們的寬和高。 在工程的res\values\目錄下建立一個dimens.xml尺寸資源檔。Java代碼:<?xml version="1.0"
Time of Update: 2018-12-04
自android3.0來Action Bar就取代了OptionsMenu。於是就涉及了API的設定。 1) 設定<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="11" />,表明應用程式可部署於android3.0或之前。也就是說當裝置的SdkVersion==11時,應用程式將啟動Action Bar。但是如何應用程式想使用Action Bar
Time of Update: 2018-12-04
在Android遊戲開發之旅二中我們講到了View和SurfaceView的區別,今天Android123從View類開始著重的介紹 Android圖形顯示基類的相關方法和注意點。(文/Android開發網)自訂View的常用方法:onFinishInflate() 當View中所有的子控制項均被映射成xml後觸發onMeasure(int, int) 確定所有子項目的大小onLayout(boolean, int, int, int, int)
Time of Update: 2018-12-05
將LMbench移植到Android上LMbench是個可移植的,用於評價系統綜合效能的多平台開源benchmark,能夠測試包括文檔讀寫、記憶體操作、進程建立銷毀開銷、網路等效能。通過以下步驟操作,即可將LMbench移植到Android上。1.下載LMbench源碼傳送門:http://www.bitmover.com/lmbench/get_lmbench.html2.編輯scripts/os 添加 OS=arm-linux$vim scripts/os#!/bin/shif [
Time of Update: 2018-12-05
拖動控制項原理其實很簡單,重寫activity的onTouchEvent方法,根據手指所在位置得到x,y座標,再用AbsoluteLayout把指定的控制項設定到該位置。首先,必須用AbsoluteLayout絕對布局:<?xml version="1.0" encoding="utf-8"?><AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
Time of Update: 2018-12-05
1.Android端:1.1 布局檔案:<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"
Time of Update: 2018-12-05
伺服器端servlet:Java codepackage sei.servlet;import java.io.IOException;import java.util.*;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import
Time of Update: 2018-12-05
這裡主要是轉載了日月之明的部落格,連結:http://www.cnblogs.com/lhming/archive/2012/06/27/2566460.html 1、android SDK+NDK安裝1)、安裝java jdk(如果已經安裝了,可以不用此步驟)進入:http://www.oracle.com/technetwork/java/javase/downloads/index.html 或者直接點擊下載。如 選擇JDK DOWNLOAD(android
Time of Update: 2018-12-05
1.在service中重寫下面的方法,這個方法有三個傳回值, START_STICKY是service被kill掉後自動重寫建立@Overridepublic int onStartCommand(Intent intent, int flags, int startId) {return START_STICKY;}----------------@Overridepublic int onStartCommand(Intent intent, int flags, int startId)