Time of Update: 2017-01-19
複製代碼 代碼如下:package com.example.playtabtest.view;import com.example.playtabtest.R;import android.app.Activity;import android.content.Context;import android.support.v4.view.ViewPager;import android.support.v4.view.ViewPager.OnPageChangeListener;import
Time of Update: 2017-01-19
今天記錄一下TextView的倒影效果,顯示一串文字,然後在文字的下方顯示出它的倒影,先上效果圖:最重要的就是View中getDrawingCache()方法,該方法可以擷取cache中的映像,然後繪製出來。廢話不多說,我是想寫一個帶有倒影的時間,時間可以走動。首先先寫一個帶有時間走動的View,這個很簡單,擷取目前時間,然後開啟一個線程,隔一秒擷取目前時間一次,然後顯示在TextView上,當然,我們寫控制項,就需要繼承TextView,代碼如下:複製代碼 代碼如下:package
Time of Update: 2017-01-19
PopupWindow是一個彈出式視窗,它可以展示任意View。他會浮在當前視窗的上方展示。下面看代碼:複製代碼 代碼如下:public class MyActivity extends Activity{ private PopupWindow menu; private LayoutInflater inflater; private View layout; &
Time of Update: 2017-01-19
, Android中實現了預設的進度提示對話方塊,即ProgressDialog,通過執行個體化和一些簡單設定,就可以使用了。複製代碼 代碼如下:private class DownloadDBTask extends AsyncTask<String, Integer, String> { //
Time of Update: 2017-01-19
Service的生命週期 (適用於2.1及以上)1. 被startService的無論是否有任何活動綁定到該Service,都在後台運行。onCreate(若需要) -> onStart(int id, Bundle args). 多次startService,則onStart調用多次,但不會建立多個Service執行個體,只需要一次stop。該Service一直後台運行,直到stopService或者自己的stopSelf()或者資源不足由平台結束。2.
Time of Update: 2017-01-19
Java 官網對Looper對象的說明:public class Looperextends ObjectClass used to run a message loop for a thread. Threads by default do not have a message loop associated with them; to create one, call prepare() in the thread that is to run the loop, and then
Time of Update: 2017-01-19
使用Button時為了讓使用者有“按下”的效果,有兩種實現方式:1.在代碼裡面。複製代碼 代碼如下:imageButton.setOnTouchListener(new OnTouchListener(){ @
Time of Update: 2017-01-19
首先還是xml布局檔案,在其中添加ListView控制項:主布局layout_main.xml複製代碼 代碼如下:<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
Time of Update: 2017-01-19
首先是布局檔案,這裡需要兩個布局檔案,一個是放置清單控制項的Activity對應的布局檔案 main.xml,另一個是ListView中每一行資訊顯示所對應的布局 list_item.xml 這一步需要注意的問題是ListView 控制項的id要使用Android系統內建的 android:id="@android:id/list" [注意形式]main.xml複製代碼 代碼如下:<?xml version="1.0"
Time of Update: 2017-01-19
布局檔案複製代碼 代碼如下:<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
建立started service 應用組件(例如Activity)調用startService()來啟動一個Service,將需要的參數通過Intent傳給Service,Service將會在onStartCommand函數中獲得Intent。有兩種方式可以建立started
Time of Update: 2017-01-19
複製代碼 代碼如下:private void open(String fileString) { Intent intent = new Intent(); intent.setClassName("com.rarlab.rar", "com.rarlab.rar.MainActivity"); File file = new File(fileString); Uri data =
Time of Update: 2017-01-19
主介面xml檔案複製代碼 代碼如下:<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
主要代碼:(有注釋)複製代碼 代碼如下:package com.example.checkboxtest;import android.annotation.SuppressLint;import android.content.Context;import android.graphics.Canvas;import android.graphics.Color;import android.os.Handler;import android.os.Message;import
Time of Update: 2017-01-19
個例子實現的功能是:1,安裝程式後看的一個Activity程式介面,裡面有個按鈕,點擊按鈕就會啟動一個Service服務,此時在設定程式管理裡面會看的有個Activity和一個Service服務運行2,如果手機關機重啟,會觸發你的程式裡面的Service服務,當然,手機啟動後是看不到你的程式介面。好比手機裡面內建的鬧鐘功能,手機重啟看不到鬧鐘設定介面只是啟動服務,時間到了,鬧鐘就好響鈴提醒。程式碼是:首先要有一個用於開機啟動的Activity,給你們的按鈕設定OnClickListener();
Time of Update: 2017-01-19
最近一直想做下拉重新整理的效果,琢磨了好久,才走到通過onTouch方法把整個視圖往下拉的步驟,接下來就是能拉下來,鬆開手要能滑回去啊。網上看了好久,沒有找到詳細的下拉重新整理的例子,只有自己慢慢琢磨了。昨天和今天,研究了兩天,下拉之後復原回去的效果終於今天做出來了!開心。現在來分享下我的實現方法和一些心得體會吧。我看了網上一個大神的例子,發現是在onTouch裡面使用View的scrollTo(int,
Time of Update: 2017-01-19
最近做的一個小東西遇到這樣的情況,我從一個頁面MainActivity修改一些內容,需要跳轉到一個新的EditActivity去做修改操作,修改完成後就回到之前的MainActivity,因為資訊被修改了,最好還是從伺服器上重新擷取一下,那麼就要在MainActivity裡重新擷取,假如把重新擷取資料的操作放在MainActivity的onStart()方法裡,那麼MainActivity跳轉到其它的地方再回來不需要請求資料的,它也必然會又請求一次,這樣就白白的增大了伺服器的壓力。也就是說,要能
Time of Update: 2017-01-19
Hybrid App 是混合模式應用的簡稱,兼具 Native App 和 Web App 兩種模式應用的優勢,開發成本低,擁有 Web 技術跨平台特性。目前大家所知道的基於中介軟體的移動開發架構都是採用的 Hybrid 開發模式,例如國外的 PhoneGap、Titanium、Sencha,還有國內的 AppCan、Rexsee 等等。Hybrid App 開發模式正在被越來越多的公司和開發人員所認同,相信將來會成為主流的行動裝置 App開發模式。Hybrid App 融合 Web App
Time of Update: 2017-01-19
一、布局檔案part.xml:複製代碼 代碼如下:<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
一、在 AndroidManifest.xml檔案中配置Widgets:複製代碼 代碼如下:<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.widget" android:versionCode="1" android:versionName="1.0"