Time of Update: 2018-12-08
SlidingDrawer隱藏屏外的內容,並允許使用者通過handle以顯示隱藏內容。它可以垂直或水平滑動,它有倆個View組成,其一是可以拖動的handle,其二是隱藏內容的View.它裡面的控制項必須設定布局,在布局檔案中必須指定handle和content。1、布局layou檔案複製代碼 代碼如下:<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="
Time of Update: 2018-12-08
我們知道Intent的應用,可以啟動別一個Activity,那麼是否可以啟動別外的一個應用程式呢,答案是可以的。1、首先我們建立一個Android應用,名為AnotherPro,此應用什麼內容都沒有,用於被另外一個程式開啟。2、建立一個工程用於開啟上面的應用,程式介面如下3、修改程式碼,在onCreate中添加如下代碼anotherPro = (Button) findViewById(R.id.startAnotherPro);calendar = (Button) findViewById(
Time of Update: 2018-12-08
需求:預設為"00:00:00",點擊開始按鈕時清零後開始計時,出現如10:28:34。點擊停止的時候停止計時。問題:使用Calendar DateFormat的方法,不設定時區擷取到的小時是本地時區的(東八區的就是8),設定成GMT標準時區擷取到的時間是12小時(12:00:00),設定24小時制無效。在開始時間加減各種小時都無效,而且計時只能到12小時就自動跳上去了,始終無法出現預設狀態00:00:00開始計時的效果。嘗試各種時間設定方法無效後只能自己寫一個根據秒數轉換時間格式字串的方法了,
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
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
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
FragmentManager 為了管理Activity中的fragments,需要使用FragmentManager. 為了得到它,需要調用Activity中的getFragmentManager()方法。 因為FragmentManager的API是在Android 3.0,也即API level 11開始引入的,所以對於之前的版本,需要使用support library中的FragmentActivity,並且使用getSupportFragmentManager()方法。
Time of Update: 2018-12-08
複製代碼 代碼如下:private InetAddress getBroadcastAddress() throws IOException { WifiManager myWifiManager = (WifiManager) getSystemService(WIFI_SERVICE); DhcpInfo myDhcpInfo = myWifiManager.getDhcpInfo(); if (myDhcpInfo == null) { System.out.println("Could
Time of Update: 2018-12-08
(效果如所示)其實很簡單:比方說上面的容器是一個ListView複製代碼 代碼如下:<ListView android:id="@+id/listView_devices" android:layout_width="fill_parent" android:layout_height="fill_parent" <SPAN style="COLOR: #ff0000">
Time of Update: 2018-12-08
在軟體開發過程中,程式碼的複用,是非常重要的概念。我們總是需要使用一些現有的模組、包、架構,或開發自己的模組、包、架構,來實現對程式碼的複用。比如在JavaWeb編程過程中,經常使用的Struts和Spring等架構,就可以大大簡化我們的開發過程,提高開發效率。
Time of Update: 2018-12-08
android中提供了4中動畫: AlphaAnimation 透明度動畫效果 ScaleAnimation 縮放動畫效果 TranslateAnimation 位移動畫效果 RotateAnimation 旋轉動畫效果 本節講解ScaleAnimation 動畫, ScaleAnimation(float fromX, float toX, float fromY, float toY,int pivotXType, float pivotXValue, int pivotYType,
Time of Update: 2018-12-08
現在我們就來看看怎麼樣把圖片的四角都變成圓形的,為什麼要這樣做那,如果要是這樣介面就會非常的美觀,下面我們就來看看代碼吧。 java代碼: 複製代碼 代碼如下:public static Bitmap toRoundCorner(Bitmap bitmap, int pixels) { Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888); Canvas
Time of Update: 2018-12-08
複製代碼 代碼如下:<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/layout" android:orientation="vertical" android:layout_width="wrap_content"
Time of Update: 2018-12-08
可以使用 Intent.createChooser() 的方法來建立 Intent,並傳入想要的 Sting 作為標題。 以wallpaper 選擇框為例,當在Launcher workspace的空白地區上長按,會彈出wallpaper的選擇框,選擇框的標題為”Choose wallpaper from”,如下: 複製代碼 代碼如下:private void startWallpaper() { showWorkspace(true); final Intent pickWallpaper =
Time of Update: 2018-12-08
本人小菜一個。目前只見過兩種彈出框的實現方式,第一種是最常見的PopupWindow,第二種也就是Activity的方式是前幾天才見識過。感覺很霸氣哦。沒想到,activity也可以做偽視窗。 先貼上最常見的方法,主要講activity的方法。 一、彈出PopupWindow 複製代碼 代碼如下:/** * 彈出menu菜單 */ public void menu_press(){ if(!menu_display){ //擷取LayoutInflater執行個體 inflater =
Time of Update: 2018-12-08
建立一個MainActivity.java的主類 複製代碼 代碼如下:<?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"
Time of Update: 2018-12-08
1.最後程式打包的時候,res檔案夾中的檔案只有用到的時候才會打包進去,而assets檔案夾中的檔案無論是否用到都要打包進去 2.安卓主要依靠xml檔案來布局,否則textView多的時候布局起來會比較混亂 3.android:singleLine屬性為true表示文本在一行顯示 android:ellipsize屬性:設定當文本過長時該如何顯示(顯示省略符號)start、end、middle分別設定省略符號的位置,marquee表示以跑馬燈的形式展示
Time of Update: 2013-10-28
本節分兩部分: 1.訪問SD卡. 2.訪問手機中的隱藏檔夾. 3.讀取assets中的檔案. 一.訪問SD卡: 1.介面編輯(reslayoutmain.xml): [java] android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > androi
Time of Update: 2013-10-28
可以通過RasterMap的getDirection()方法來查詢路徑,和查詢地址類似,路徑查詢的結果也是通過回呼函數的方式來通知應用程式的,下面的例子返回南京到北京的路徑。返回結果存放在MapDirection中,MapDirection包含了路徑的詳細資料,包括路徑的每個步驟,長度,時間,方向等。 Java代碼: packageeoe.demo; importcom.mapdigit.gis.MapDirection; importcom.mapdigit.gis.M