Time of Update: 2017-01-19
本文執行個體講述了Android線程中設定控制項的值提示報錯的解決方案。分享給大家供大家參考,具體如下:在Android線程中設定控制項的值一般會與Handler聯合使用,如下:package com.yarin.android.Examples_04_15;import android.app.Activity;import android.os.Bundle;import android.os.Handler;import android.os.Message;import android.
Time of Update: 2017-01-19
Android中的控制項的使用方式和iOS中控制項的使用方式基本相同,都是事件驅動。給控制項添加事件也有介面回調和委託代理的方式。今天這篇部落格就總結一下Android中常用的基本控制項以及布局方式。說到布局方式Android和iOS還是區別挺大的,在iOS中有Frame絕對布局和AutoLayout相對布局。而在Android中的布局方式就比較豐富了,今天部落格中會介紹四種常用的布局方式。先總結一下控制項,然後再搞一搞基本方式,開發環境還是用的Mac下的Android
Time of Update: 2017-01-19
本文總結分析了Android EditText常用屬性。分享給大家供大家參考,具體如下:android:hint="請輸入數字!"//設定顯示在空間上的提示資訊android:numeric="integer"//設定只能輸入整數,如果是小數則是:decimalandroid:singleLine="true"//設定單行輸入,一旦設定為true,則文字不會自動換行。android:password="true"//設定只能輸入密碼android:textColor =
Time of Update: 2017-01-19
1.首先是註冊頁面的布局:<?xml version="1.0" encoding="utf-8"?><LinearLayout
Time of Update: 2017-01-19
本文執行個體講述了Android編程實現表徵圖拖動效果的方法。分享給大家供大家參考,具體如下:最近最佳化表徵圖拖動時的速率,稍微有一點點效果,直接把代碼貼出來,有興趣一起討論的朋友可以給我留言。代碼如下:DragView.javapackage com.android.dragtest;import android.content.Context;import android.util.AttributeSet;import android.util.Log;import
Time of Update: 2017-01-19
本文執行個體講述了Android編程實現檢測當前電源狀態的方法。分享給大家供大家參考,具體如下:檢測到現在在電源狀態:IntentFilter mIntentFilter = new IntentFilter();mIntentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);registerReceiver(mIntentReceiver, mIntentFilter);//聲明訊息處理過程 private BroadcastReceiver
Time of Update: 2017-01-19
本文執行個體講述了Android編程實現擦除Bitmap中某一塊的方法。分享給大家供大家參考,具體如下:以前要截取Bitmap中的圖片使用的一塊塊的拼接,雖然可以實現,但是效率很低。想了很久,無意中看到網上的對BITMAP圖片的RGB資訊進行修改,然後想出了這個辦法,感覺用起來還是挺舒服。很多出錯處理都沒有寫,只實現準系統啊public static Bitmap setTransparentAreaForBitmap(Bitmap b, int width, int height,
Time of Update: 2017-01-19
本文執行個體講述了Android編程擷取sdcard音樂檔案的方法。分享給大家供大家參考,具體如下:複製代碼 代碼如下:Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder);Uri:指明要查詢的資料庫名稱加上表的名稱,從MediaStore中我們可以找到相應資訊的參數,具體請參考開發文檔。Projection:
Time of Update: 2017-01-19
本文執行個體講述了Android編程擷取sdcard卡資訊的方法。分享給大家供大家參考,具體如下:public static SDCardInfo getSDCardInfo() { String sDcString = android.os.Environment.getExternalStorageState(); if (sDcString.equals(android.os.Environment.MEDIA_MOUNTED)) { File pathFile =
Time of Update: 2017-01-19
本文執行個體講述了Android編程實現應用強制安裝到手機記憶體的方法。分享給大家供大家參考,具體如下:在Froyo(android 2.2,API Level:8)中引入了android:installLocation.通過設定該屬性可以使得開發人員以及使用者決定程式的安裝位置.android:installLocation隸屬於AndroidManifest.XML中的manifest節點.如下所示:<manifest
Time of Update: 2017-01-19
本文執行個體講述了Android編程實現仿iphone抖動效果的方法。分享給大家供大家參考,具體如下:布局檔案:<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"
Time of Update: 2017-01-19
本文執行個體講述了Android編程實現Gallery中每次滑動只顯示一頁的方法。分享給大家供大家參考,具體如下:import android.content.Context;import android.util.AttributeSet;import android.view.KeyEvent;import android.view.MotionEvent;import android.widget.Gallery;public class DetialGallery extends
Time of Update: 2017-01-19
本文執行個體講述了Android編程之代碼建立布局使用方法。分享給大家供大家參考,具體如下:大概描述一下效果:最外層是一個 RelativeLayout 裡面有自訂個LinearLayout,每個LinearLayout有兩個TextView。that's it !!!private void initView() { // 擷取xml的RelativeLayout layout = (RelativeLayout) findViewById(R.id.liner); for (int
Time of Update: 2017-01-19
本文執行個體講述了Android編程之防止反編譯的實現方法。分享給大家供大家參考,具體如下:1. 判斷程式是否運行在模擬器上boolean isRunningInEmualtor() { boolean qemuKernel = false; Process process = null; DataOutputStream os = null; try{ process = Runtime.getRuntime().exec("getprop ro.kernel.qemu");
Time of Update: 2017-01-19
本文執行個體講述了Android編程實現仿心跳動畫效果的方法。分享給大家供大家參考,具體如下:// 按鈕類比心臟跳動private void playHeartbeatAnimation() { AnimationSet animationSet = new AnimationSet(true); animationSet.addAnimation(new ScaleAnimation(1.0f, 1.8f, 1.0f, 1.8f,
Time of Update: 2017-01-19
本文執行個體講述了Android編程之介面跳動提示動畫效果實現方法。分享給大家供大家參考,具體如下:上一個效果圖:先上布局:<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
Time of Update: 2017-01-19
本文執行個體講述了Android編程實現TextView部分顏色變動的方法。分享給大家供大家參考,具體如下:public class StringHandleExampleActivity extends Activity { /** Called when the activity is first created. */ private TextView textView; private String tempStr = "abcd12我的中古zx9yu5!f3,,";
Time of Update: 2017-01-19
本文執行個體講述了Android編程使用自訂shape實現shadow陰影製作效果的方法。分享給大家供大家參考,具體如下:直接上xml檔案, 並且附上相應的解析:<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true">
Time of Update: 2017-01-19
本文執行個體講述了Android編程實現WebView全屏播放的方法。分享給大家供大家參考,具體如下:最近因為項目要用webview載入html5的視頻,開始不能全屏播,做了很久才做出來!那按我的理解說下怎麼實現全屏吧。首先寫布局檔案activity_main.xml:<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
Time of Update: 2017-01-19
本文執行個體講述了Android編程實現基於區域網路udp廣播自動建立socket串連的方法。分享給大家供大家參考,具體如下:android開發中經常會用到socket通訊。由於項目需要,最近研究了一下這方面的知識。 需求是想通過wifi實現android行動裝置和android平台的電視之間的檔案傳輸與控制。