• This is Slide 1 Title

    This is slide 1 description. Go to Edit HTML and replace these sentences with your own words.

  • This is Slide 2 Title

    This is slide 2 description. Go to Edit HTML and replace these sentences with your own words.

  • This is Slide 3 Title

    This is slide 3 description. Go to Edit HTML and replace these sentences with your own words.

2018年2月12日 星期一

Android Studio:Gradle的更新方法

至官網下載最新版本或其他版本,下載後解下縮:
最新:https://gradle.org/release-candidate/
其他:http://services.gradle.org/distributions/

File>Settings>Build,Execution,Deployment>Gradle>Use local gradle distribution>選取檔案位置



Android Studio:將專案匯出為 APK及匯出位置

選擇Build>Build APK(s)






APK位置:

先用Project預覽模式下查尋>於專案名稱下的bulid>outputs>apk>debug的資料夾內

2017年12月9日 星期六

Android Studio:退出/刪除活動頁(Activity)。

進入新活動頁(Activity)時,刪除舊活動頁(Activity)不能從後退按鈕再次訪問。
你只需要調用finish()
ex. Intent intent = new Intent(this, NextActivity.class); startActivity(intent); finish();



2017年11月11日 星期六

Android Studio:Activity上方Menu選單製作

New/Android resource file產生一備資源檔。


其Reource type定義為「Menu」,再輸入檔名為menu_main.xml。


其實選單位置在res/menu/menu_main.xml。



於menu_main.xml中加入item元素,並設定android:id、android:title、app:showAsAction三屬性。


app:showAsAction為其在ToolBar上顯示之原則,其屬性有:
  • never:不會顯示
  • ifRoom:有空間就顯示
  • always:都顯示
  • withText:除icon圖示外,也顯示item的標題文字
android:orderInCategory為整數,菜單項目順序,數字越小的越前面

Android Studio:finish()、onDestory()、System.exit(0)的區別

Activity.finish():將Activity移出線,其還占用資源沒有被釋放,所以按手機"back"按鍵的時候,也找不到這個Activity。

Activity.onDestory():為Activity的生命周期中,之最后一步,釋放其資源,故要重新進入此Activity的時候,必須重創建,執行onCreate()方法。

System.exit(0):將Application退出整個用程序。

2017年11月9日 星期四

Android Studio:什麼是 Views?

Activity類別即是視窗(window),而視窗內放置的UI/物件(ex.button),即是View類別,其功用是繪製UI與處理事件(event)。

事件監聽器(event listener),就是使用者對這個UI(view)進行某項操作時(ex.Click),這個事件監聽器被回呼函數而執行動作。

2017年11月6日 星期一

Android Studio:對話視窗/AlertDialog


常被使用的元件如下:
  • 選單(Menu)
  • 對話盒(Dialog)
  • 快顯訊息(Toast)
所以AlertDialog對話盒,可用來詢問使用者問題或偏好。

AlertDialog 的用法:它不能像其它的類別可以直接利用 new 來產生一個 AlertDialog 的物件,而必須借用 AlertDialog.Builder() 來產生物件。

public void onClick(DialogInterface dialog, int which) {
//直接關閉 對話方塊
}

MyAlertDialog.setPositiveButton("左邊按鈕",OkClick );
MyAlertDialog.setNeutralButton("中間按鈕",OkClick );
MyAlertDialog.setNegativeButton("右邊按鈕",OkClick );
MyAlertDialog.show();