原创 getView的原理

public View getView(int position, View convertView, ViewGroup parent)  ListView控件中的viewitem數目只能剛好充滿屏幕,翻頁的過程中它只是用舊的v

原创 有關於service服務的總結

1,startservice的特點:不是多線程的,服務裏如果有耗時長的操作將會導致anr錯誤,多次啓動服務的話,oncreate()只調用一次,每次啓動服務將會調用重新調用onstartcommand()客戶端調用service服務的代

原创 activity狀態的保存與恢復機制,生命週期

啓動的activity 按home鍵: 按返回鍵: 按home鍵後又重新啓動該應用: activity狀態的保存與恢復機制

原创 關於一些Android控件園邊的設計

在控件的android:backgroud屬性中使用shapedrawable資源可以做各種外觀的控件 以下是輸入框圓角的設計 <shape xmlns:android="http://schemas.android.com/apk/

原创 TabHost的使用

public class TabHostAc extends TabActivity { @Override protected void onCreate(Bundle savedInstanceState) { // TOD

原创 oncreatedialog()與showdialog()的使用

package com.lin.db; import android.app.AlertDialog; import android.app.Dialog; import android.app.ListActivity; import

原创 ExpandableListActivity

public class ExpandLV extends ExpandableListActivity { @Override protected void onCreate(Bundle savedInstanceState)

原创 使用XmlPullParser解析xml文件

<?xml version="1.0" encoding="UTF-8"?> <persons>     <person id="23"> <nam

原创 getcontext與getapplicationcontext()的區別

public class MyActivity extends Activity {     public void method() {        mContext = this;    // since Activity exte

原创 有關於子控件填充容器的異常說明

java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's pa

原创 使用webview加載,注意事項

在android應用中,有時要加載一個網頁,如果能配上一個進度條就更好了,而android  中提供了其很好的支持,下面是一個例子程序,先帖:  1 2 3 4 <?xml version

原创 android 獲取string.xml中的value

 其實所有的常量,默認值都應在string.xml裏定義。這樣修改起來也方便。按道理修改後並不需要從新build就能起作用(沒試過)。         但大家知道R.string.xxx的值是自動生成的int, 如何得到真正的string

原创 Android 屏幕(View)座標系統

首先明確一下 android中的座標系統 :屏幕的左上角是座標系統原點(0,0),原點向右延伸是X軸正方向,原點向下延伸是Y軸正方向。一、View的座標 需要注意view的座標是相對父容器而言的,包括:getTop()、getBottom

原创 android:layout_gravity和android:gravity的使用區別。

android:gravity: 這個是針對控件裏的元素來說的,用來控制元素在該控件裏的顯示位置。例如,在一個Button按鈕控件中設置如下兩個屬性, android:gravity="left"和android:text="提交"

原创 android照相、相冊獲取圖片剪裁報錯的解決方法

最近在項目中用到了照相和相冊取圖剪裁上傳頭像,就在網上逛了逛,基本都是千篇一律,就弄下來用了用,沒想到的是各種各樣的奇葩問題就出現了。先給大家看看代碼問題慢慢來解決 這是調用相機  public static File ge