Time of Update: 2017-01-19
前言大家都知道Android Studio目前已經更新到2.0 Preview 6了,作為Google大力推崇的開發工具,相對於Eclipse ADT有著不可比擬的優勢。然而在實際使用時,依然有不少不爽的地方。Android
Time of Update: 2017-01-19
有時我們在應用中會用到圓形頭像,下面是利用CircleImageView實現圓形頭像的示範,下面效果和代碼,效果如圖實現起來也比較簡單,先在項目中建一個circleimageview包用來存放CircleImageView類,待會直接把CircleImageView類複製到包裡就可以使用了然後,再建一個attrs.xml,其代碼相當簡單,定義了圓形邊框寬度和顏色<?xml version="1.0"
Time of Update: 2017-01-19
方法一複製代碼 代碼如下:public static boolean isTablet(Context context) { return
Time of Update: 2017-01-19
android開發中為activity增加左右手勢識別,如右滑關閉當前頁面。複製代碼 代碼如下:/* * for左右手勢 * 1.複製下面的內容到目標Activity * 2.目標Activity的onCreate()調用initGesture() * 3.目標Activity需implements OnTouchListener, OnGestureListener */
Time of Update: 2017-01-19
複製代碼 代碼如下:package com.test.mytest.widget;import java.util.List;import android.content.Context;import android.os.Handler;import android.util.AttributeSet;import android.widget.LinearLayout;import android.widget.TextView;public class
Time of Update: 2017-01-19
這是我們最常見的一類模式,對這一類模式有一個通用的特點就是:封裝建立的方式和過程。這裡所謂封裝就是隱藏的意思,對對象的建立方法和過程不可見,或者是虛擬過程。隱藏建立方式,就是如單例,Factory 方法,隱藏建立過程則是指builder,原型,至於抽象工廠,我認為他包含了以上兩種。我們想想一個對象的建立有哪些步驟?1、建立什麼東西?--介面定義2、誰建立?
Time of Update: 2017-01-19
PC上的瀏覽器會彈出認證錯誤的對話方塊,提示你是否要無視錯誤繼續瀏覽。實際上在WebView裡也可以這樣做,以實現載入認證有問題的頁面。複製代碼 代碼如下:WebView webview = (WebView) findViewById(R.id.webview);webview.setWebViewClient(new WebViewClient() { @Override public void
Time of Update: 2017-01-19
使用要點如下:1.利用ListAdapter(一般使用ArrayAdapter)為AutoCompleteTextView提供資料,若有需要還可以重載getView()以自訂欄表項的顯示方式。這一步同ListView。2.如果需要根據輸入內容進行動態提示,那麼adapter需要實現Filterable介面,重載getFilter()函數實現提示演算法。getFilter()需返回Filter對象,該對象包含至少兩個方法:performFiltering()在後台執行過濾,publishResul
Time of Update: 2017-01-19
複製代碼 代碼如下:package cn.aibow.android.layoutdemo1;import android.os.Bundle;import android.app.Activity;import android.view.Menu;import android.view.MotionEvent;import android.view.View;import android.widget.TextView;import android.widget.Toast;public
Time of Update: 2017-01-19
最近項目中經常需要用到自訂控制項,因此自訂屬性也是經常要用到的,在此說明一下自訂屬性的用法:自訂屬性都存在於/value/attr.xml檔案中,以如下格式存在。複製代碼 代碼如下:<resource><declare-styleable name="自訂屬性名稱"><attr name="屬性名稱"
Time of Update: 2017-01-19
先讓大家看看效果圖吧,相信很多Android初學者都想知道這中效果是怎麼實現的,來上圖: 想實現上面這張圖中的自訂載入樣式,其實很簡單,首先我們需要的布局組件有ProcessBar和TextView,下面是布局檔案的代碼(只是載入的頁面的布局): 複製代碼 代碼如下: <?xml version="1.0" encoding="utf-8"?> <LinearLayout
Time of Update: 2017-01-19
定義廣播接收器的Action:複製代碼 代碼如下:private static final String TAG ="SmsService";/*** 資訊發送狀態廣播*/private static final String ACTION_SMS_SEND = "com.SmsService.send"; /*** 資訊接收狀態廣播*/private static final String ACTION_SMS_DELIVERY =
Time of Update: 2017-01-19
在oncreate 中執行:複製代碼 代碼如下:public void onCreate() { super.onCreate(); Log.i("TAG", "服務啟動了"); // 對電話的來電狀態進行監聽 TelephonyManager telManager = (TelephonyManager) this
Time of Update: 2017-01-19
複製代碼 代碼如下:new TimePickerDialog(MainActivity.this, new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute)
Time of Update: 2017-01-19
複製代碼 代碼如下:<Switchandroid:id="@+id/open"android:layout_width="wrap_content"android:layout_height="wrap_content"android:textOff="藍芽關閉中"android:textOn="藍芽開啟中" />複製代碼 代碼如下:open.setOnCheckedChangeListener(new OnCheckedChangeListener()
Time of Update: 2017-01-19
android通過google API擷取天氣資訊複製代碼 代碼如下:public class WeatherActivity extends Activity { private TextView txCity; private Button btnSearch; private Handler weatherhandler; private Dialog progressDialog; private Timer
Time of Update: 2017-01-19
1,USB存放裝置(如:隨身碟,移動硬碟): //USB存放裝置 插拔監聽與 SD卡插拔監聽一致。複製代碼 代碼如下: private USBBroadCastReceiver mBroadcastReceiver; IntentFilter iFilter = new IntentFilter();
Time of Update: 2017-01-19
複製代碼 代碼如下:private void callToWebSrvice() { ConnectivityManager connManager = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE); if
Time of Update: 2017-01-19
一、Monkey 是什嗎?Monkey 就是SDK中附帶的一個工具。 二、Monkey 測試的目的?:該工具用於進行壓力測試。 然後開發人員結合monkey 列印的日誌 和系統列印的日誌,結局測試中出現的問題。三、Monkey 測試的特點?Monkey 測試,所有的事件都是隨機產生的,不帶任何人的主觀性。四、Monkey 命令詳解1).標準的monkey 命令[adb shell] monkey [options] <eventcount> , 例如:adb shell
Time of Update: 2017-01-19
(1).解析Object之一:複製代碼 代碼如下:{"url":"http://www.cnblogs.com/qianxudetianxia"}解析方法:複製代碼 代碼如下:JSONObject demoJson = new JSONObject(jsonString);String url = demoJson.getString("url");(2).解析Object之二:複製代碼 代碼如下:{"name":"android","name":"iphone"}解析方法:複製代碼 代碼如下: