顯示具有 App開發基本功 標籤的文章。 顯示所有文章
顯示具有 App開發基本功 標籤的文章。 顯示所有文章

2013年9月17日 星期二

2013年8月19日 星期一

App Icon image & Icon title


AndroidManifest.xml


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.cookbook.simple_activity"
          android:versionCode="1"
          android:versionName="1.0">
    <application android:icon="@drawable/icon"
                  android:label="@string/app_name">
        <activity android:name=".SimpleActivity"
                   android:label="@string/app_name">

2013年8月15日 星期四

殺死執行中的App

1. 從DDMS選擇執行中的Process
2. 點選Stop button



實機測試

要偵測到實機,
機器要做以下設定

1. Device 的  Settings -> Security  -> Unknown sources 打開

2. Settings -> Developer options -> usb debugging 打開




                         


從DDMS看 device清單





2013年8月14日 星期三

Model View Controller

In Android, a controller is typically a subclass of Activity, Fragment, or Service.

設定listener


ex

JAVA:

   mTrueButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
            Toast.makeText(MainActivity.this, "Correct", Toast.LENGTH_SHORT).show();
            }
        });
     
        mFalseButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
        Toast.makeText(MainActivity.this, "Wrong", Toast.LENGTH_SHORT).show();
            }
        });


XML:


    <Button
           android:id="@+id/editPlanWorkButton"
    android:layout_width="0dp"
    android:layout_height="44dp"
    android:textColor="#000000"
     android:background="@drawable/roundcornerforplanworkbutton"
      android:layout_alignParentRight="true"
      android:text="靜態活動(大部份時間都坐著)"
android:layout_toRightOf="@id/editPlanWorkTextView"
    android:layout_alignBottom="@id/editPlanWorkTextView"
        android:layout_marginLeft="12dp"
    android:textSize="14sp"
  android:onClick="editPlanWorkButtonClick"
      />

organize imports

分析專案的code後,自動import需要的class

mac: Command + Shift + O


Resource


A resource is a piece of your application that is not code – things like image files, audio files, and XML files.


To access a resource in code, you use its resource ID

resource ID is int

查詢Resource ID

gen/R.java





android:id="@+id/example"

The at symbol (@) signifies that you’re referring to a resource rather than providing a literal value. The plus (+) indicates that you are creating a new resource reference; without it, you’re referring to an existing resource reference. Then comes id, defining what type of resource it is. Finally, you have the name of the resource

directory res is for resource

Resource Qualifiers
By using resource “qualifiers,” you can let Android take care of this for you.
A qualifier is a portion of a directory’s name that marks its contents as being used for a specific situation
ex:

ldpi
mdpi
hdpi



resource folder name

animator: Property animations defined in XML.
anim: View animations defined in XML.
color: State lists of colors defined in XML. State lists are covered later in this chapter.
drawable: Drawable assets that can be defined in XML or image files (PNG, GIF, or JPG).
layout: Layouts defined in XML.
menu: Menus such as the action bar menu defined in XML.
raw: Any raw files such as audio files and custom bytecode.
values: Various simple values defined in XML, such as strings, floats, and integer colors.
xml: Any XML files you wish to read at runtime.


other resources:
Strings

Arrays
Colors
Dimensions
Animations




建立新專案

1. File -> New -> Project



 2. Android -> Android Application Project



 3. 設定Application Name為miniHana

預設Application Name欄位會連帶影響Project Name和Package Name欄位


4. 取消Create custom launcher icon的勾選


5. 設定建立Blank Activity


6. 設定Activity和Layout的名稱



7. 完成建立專案