長度單位有dp, px
文字大小單位有sp,pt
為了在相同螢幕下不同解析度依然維持相同大小,
長度單位需使用dp
文字大小單位需使用sp
如果螢幕長寬比例不同, 則需要利用公式去計算比例關係
一般來說要去設定長度或文字大小有以下三種方法
1. 從程式設定
2. 從xml
3. 從dimens
2013年3月19日 星期二
2013年3月12日 星期二
java Interface, Abstract
Interface和Abstract都不能直接實體化
Interface 和 Abstract 方法大同小異, 但是主要是要符合ISP(Interface Segregation Priciple),
Abstract是為了讓子類別還具備保留父類別的抽象概念,
而因為java 不能多重繼承, 也是為了讓子類別有單獨承接父類別的概念,
但是為了有多重繼承的效果, 也就有了interface替abstract class添加新功能/屬性的概念
Interface 和 Abstract 方法大同小異, 但是主要是要符合ISP(Interface Segregation Priciple),
Abstract是為了讓子類別還具備保留父類別的抽象概念,
而因為java 不能多重繼承, 也是為了讓子類別有單獨承接父類別的概念,
但是為了有多重繼承的效果, 也就有了interface替abstract class添加新功能/屬性的概念
implements Interface 要override裡面的method
public interface DemoInterface
{
final int x=0;
void a();
void b();
void c();
}
extends Abstract 要override裡面的abstract method,
而Interface 不能描述方法, Abstract 則可以如a()
而Interface 不能描述方法, Abstract 則可以如a()
public abstract DemoAbstract
{
int y;
void a(){...};
abstract void b();
abstract void c();
}
2013年3月2日 星期六
Android onInterceptTouchEvent&onTouchEvent
在ViewGroup中可以override onInterceptTouchEvent與onTouchEvent這兩個物件,
而View中只可以override onTouchEvent這個物件,接下來將會說明他們的功能為何。
假設有 RelativeLayoutA, RelativeLayoutB, ButtonC
當我們在點擊ButtonC時, 會先由parent view收到訊息, 然後開始往child view傳。
首先,A的onInterceptTouchEvent收到down event後return false,然後會把down event會傳給的B的onInterceptTouchEvent,然後B發現它下面沒有groupview了就把down event傳給C的onTouchEvent, 如果C return true也就是告訴系統接下來的action event 都是由她處理,直接傳給他就可以了。
所以越上層的view會有優先決定處理action event的機會,那麼view的onTouchEvent何時會return true呢? 當我們在設置view的listener時,系統會認為這個view是有要處理action event的。
而View中只可以override onTouchEvent這個物件,接下來將會說明他們的功能為何。
假設有 RelativeLayoutA, RelativeLayoutB, ButtonC
當我們在點擊ButtonC時, 會先由parent view收到訊息, 然後開始往child view傳。
首先,A的onInterceptTouchEvent收到down event後return false,然後會把down event會傳給的B的onInterceptTouchEvent,然後B發現它下面沒有groupview了就把down event傳給C的onTouchEvent, 如果C return true也就是告訴系統接下來的action event 都是由她處理,直接傳給他就可以了。
所以越上層的view會有優先決定處理action event的機會,那麼view的onTouchEvent何時會return true呢? 當我們在設置view的listener時,系統會認為這個view是有要處理action event的。
2013年3月1日 星期五
android focusable
在這裡的說明, 純粹是依我對focusable的了解, 所謂的focus也就是你目前注視著哪個view, 這樣的說法很抽象, 我在這裡舉個例子:
比如使用google chrom時, 有兩個tab一頁是google一頁是yahoo, 當我們取得焦點是在yahoo那頁的【網頁搜尋】UI, 我們可以藉由按鍵盤上的tab鍵來改變焦點, 或者也可以用滑鼠直接去點選。講到這裡我們得出一個結論, 能夠取得焦點的, 才能夠點選, 而以目前來說我們的焦點無法指到google那一頁面, 也就是說google 的【網頁搜尋】UI是接收不到我們的click event。
而在這例子中的google&yahoo首頁, 就是相當於android中的layout.xml,經常有人利用在自行定義listview時, 發生listitem的button搶掉listview的事件, 這原因就是在於focus原本屬於mainLayout.xml (google首頁)所以在點選listview可以去做判斷你點了什麼, 而因為自行訂定了listitem而導致焦點被自行定義的item.xml(yahoo首頁)給搶走了。
比如使用google chrom時, 有兩個tab一頁是google一頁是yahoo, 當我們取得焦點是在yahoo那頁的【網頁搜尋】UI, 我們可以藉由按鍵盤上的tab鍵來改變焦點, 或者也可以用滑鼠直接去點選。講到這裡我們得出一個結論, 能夠取得焦點的, 才能夠點選, 而以目前來說我們的焦點無法指到google那一頁面, 也就是說google 的【網頁搜尋】UI是接收不到我們的click event。
而在這例子中的google&yahoo首頁, 就是相當於android中的layout.xml,經常有人利用在自行定義listview時, 發生listitem的button搶掉listview的事件, 這原因就是在於focus原本屬於mainLayout.xml (google首頁)所以在點選listview可以去做判斷你點了什麼, 而因為自行訂定了listitem而導致焦點被自行定義的item.xml(yahoo首頁)給搶走了。
2013年2月25日 星期一
android facebook post to wall
Request request = new Request(Session.getActiveSession(), "me/feed", postParams, HttpMethod.POST, new Request.Callback(){...});
RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();這裡的postParams 是 Bundle postParams = new Bundle();
而po出的文會成為什麼樣子則要看我們利用postParam填入什麼屬性。
postParams.putString("name", "Facebook SDK for Android");
link | The link attached to this post (點選name或圖片會跳過去link) |
picture | The URL of a picture attached to this post. The picture must be at least 50px by 50px (though minimum 200px by 200px is preferred) and have a maximum aspect ratio of 3:1 (圖片上的那塊藍綠圖) |
source | The URL of a media file (either SWF or MP3) attached to this post. If both source and picture are specified, only source is used. |
name | The name of the link attachment.(圖片上的Facebook Dialog) |
caption | The caption of the link (appears beneath the link name). If not specified, this field is automatically populated with the URL of the link.(圖片上的Reference Documentation) |
description | The description of the link (appears beneath the link caption). If not specified, this field is automatically populated by information scraped from the link, typically the title of the page. (圖片上的Using Dialogs to interact with users) |
properties | A JSON object of key/value pairs which will appear in the stream attachment beneath the description, with each property on its own line. Keys must be strings, and values can be either strings or JSON objects with the keys text and href.(會接在圖片上description後面) |
actions | A JSON array containing a single object describing the action link which will appear next to the "Comment" and "Like" link under posts. The contained object must have the keys name and link."{'name'='text', 'link'='URL'}" (會在圖片上like, comment的右邊然後文字為text,連結為URL) |
http://developers.facebook.com/docs/reference/dialogs/feed/
https://developers.facebook.com/docs/reference/dialogs/
Facebook LoginButton Permissions
在新增LoginButton時,可設定可被公開的權限,那一總共有哪些
https://developers.facebook.com/docs/reference/login/extended-permissions/
final List<String> PERMISSIONS_PUBLISH = Arrays.asList("publish_actions", "publish_checkins");
LoginButton authButton=(LoginButton)findViewById(R.id.authButton);authButton.setPublishPermissions(PERMISSIONS_PUBLISH);
| Permission | Description |
|---|---|
read_friendlists | 讓你可取得使用者的好友名單 |
read_insights | 讓你可取得使用者允許的可視資料, 應用程式, 網域(domains the user owns) |
read_mailbox | 讓你可取得使用者的收件匣資訊 |
read_requests | 讓你可取得使用者的好友所發出的請求 |
read_stream | 讓你可取得使用者塗鴉牆上的News feed, 甚至具備搜尋的能力 |
xmpp_login | Provides applications that integrate with Facebook Chat the ability to log in users. |
ads_management | Provides the ability to manage ads and call the Facebook Ads API on behalf of a user. |
create_event | Enables your application to create and modify events on the user's behalf |
manage_friendlists | 讓你的程式可以建立與編輯使用者朋友群組 |
manage_notifications | Enables your app to read notifications and mark them as read. Intended usage: This permission should be used to let users read and act on their notifications; it should not be used to for the purposes of modeling user behavior or data mining. Apps that misuse this permission may be banned from requesting it. |
user_online_presence | Provides access to the user's online/offline presence |
friends_online_presence | Provides access to the user's friend's online/offline presence |
publish_checkins | 讓你的程式可以打卡 |
publish_actions | Enables your app to post content, comments, and likes to a user's stream and to the streams of the user's friends. This requires extra permissions from a person using your app. However, please note that Facebook recommends a user-initiated sharing model. Please read the Platform Policies to ensure you understand how to properly use this permission. Note, you do not need to request the publish_stream permission in order to use the Feed Dialog, the Requests Dialog or the Send Dialog. |
rsvp_event | Enables your application to RSVP to events on the user's behalf |
https://developers.facebook.com/docs/reference/login/extended-permissions/
訂閱:
文章 (Atom)

