ref:
http://givemepass.blogspot.tw/2012/01/observer-pattern.html
http://openhome.cc/Gossip/DesignPattern/ObserverPattern.htm
搜尋此網誌
2015年8月15日 星期六
2015年8月14日 星期五
【Android】工具 - RoboGuice
感覺和奶油刀差不多的工具
RoboGuice https://github.com/roboguice/roboguice/wiki
Example:
written using RoboGuice:
RoboGuice https://github.com/roboguice/roboguice/wiki
Example:
class AndroidWay extends Activity { TextView name; ImageView thumbnail; LocationManager loc; Drawable icon; String myName; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); name = (TextView) findViewById(R.id.name); thumbnail = (ImageView) findViewById(R.id.thumbnail); loc = (LocationManager) getSystemService(Activity.LOCATION_SERVICE); icon = getResources().getDrawable(R.drawable.icon); myName = getString(R.string.app_name); name.setText( "Hello, " + myName ); } }
written using RoboGuice:
@ContentView(R.layout.main) class RoboWay extends RoboActivity { @InjectView(R.id.name) TextView name; @InjectView(R.id.thumbnail) ImageView thumbnail; @InjectResource(R.drawable.icon) Drawable icon; @InjectResource(R.string.app_name) String myName; @Inject LocationManager loc; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); name.setText( "Hello, " + myName ); } }
【Android Studio】auto import all of the shortcut
心得:
從Eclipse轉到Android Studio實在太累了,一堆功能又不太一樣,一直卡在Debug要如在AS上操作比較順利,常常知道Eclipse的功能,但轉到AS不知道要去哪裡設定?再加上英文關鍵字也不知道要如何下?
比如說:
URL url = new URL();
使用eclipse時(Shift+Ctrl+O)會自動說明需要加上try ... catch ...exception 或 throws ...exception,並自動產生出來。
但在AS只會和你說 Unhandled exception: ...之類的,但是要如何解決,需要自己去查api要如何使用,沒有直接提示。
其實是有的,只是這個功能被關閉哩 (= =|||)
StackOverflower類似的問題:
Is there any way of auto importing (like in Eclipse Shift+Ctrl+O) in Android Studio?
I have found only Ctrl+Alt+O which ask for each thing, and I have to press Alt+Enter to accept it.
No way to do it faster?
For Windows/Linux, you can go to
File -> Settings -> Editor -> General -> Auto Import -> Java and make the following changes:- change
Insert imports on pastevalue toAll - mark
Add unambigious imports on the flyoption as checked
On a Mac, do the same thing in
Android Studio -> Preferences【Android】工具 - Butterknife
http://jakewharton.github.io/butterknife/
1.Download the latest JAR or grab via Maven
2.Gradle
compile 'com.jakewharton:butterknife:7.0.1'
Example
1.Download the latest JAR or grab via Maven
2.Gradle
compile 'com.jakewharton:butterknife:7.0.1'
Example
class ExampleActivity extends Activity { @Bind(R.id.user) EditText username; @Bind(R.id.pass) EditText password; @BindString(R.string.login_error) String loginErrorMessage; @OnClick(R.id.submit) void submit() { // TODO call server... } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.simple_activity); ButterKnife.bind(this); // TODO Use fields... } }
-----------------------------------------------
ButterKnife後,
讓Annotation單獨一行顯示,
不必再切成兩行,設定:
File > Settings > Editor > Code Style > Java > Filed annotations > Do not wrap after single annotation 打勾。
【Android】AsyncTask使用上的注意事項
ref:
doInBackground方法和onPostExecute的參數必須對應,這兩個參數在AsyncTask聲明的泛型參數列表中指定。
第一個為doInBackground接受的參數。
第二個為顯示進度的參數。
第三個為doInBackground返回和onPostExecute傳入的參數。
- http://blog.30sparks.com/android-asynctask-problems/
- http://themakeinfo.com/2015/04/retrofit-android-tutorial/
doInBackground方法和onPostExecute的參數必須對應,這兩個參數在AsyncTask聲明的泛型參數列表中指定。
第一個為doInBackground接受的參數。
第二個為顯示進度的參數。
第三個為doInBackground返回和onPostExecute傳入的參數。
【Android Studio】ActionBarActivity is deprecated
ref:
http://developer.android.com/tools/support-library/index.html
http://android-developers.blogspot.tw/2015/04/android-support-library-221.html
Since the version 22.1.0, the class
解決方法:
https://www.youtube.com/watch?t=49&v=5Be2mJzP-Uw
需修改以下兩處:
http://developer.android.com/tools/support-library/index.html
http://android-developers.blogspot.tw/2015/04/android-support-library-221.html
Since the version 22.1.0, the class
ActionBarActivity is deprecated. You should use AppCompatActivity.解決方法:
https://www.youtube.com/watch?t=49&v=5Be2mJzP-Uw
需修改以下兩處:
- AndroidManifest.xml
- <application android:theme="@style/Theme.AppCompat">
- MainActivity.xml
- public class MainActivity extends AppCompatActivity
2015年8月7日 星期五
2015年8月1日 星期六
【Note】防曬係數 防曬乳推薦
- 防曬能力看PA ,延後曬傷時間看SPF。
- 一般人沒有任何防備地站在陽光下面暴曬,15分鍾皮膚開始出現紅斑。
- SPF(Sun Protection Factor),指的是「防曬係數」,代表抵抗UVB的「防護時間」有多長,不過,真正在人體上的防禦時間會隨著汗水等外在環境縮短。
- 例如:SPF20 = 15分鐘x20 = 300分鐘 (會造成皮膚傷害)
- PA (Protection Grade of UVA) 是防止 UVA 的標示,用加號代表。
- PA ++ 比 PA + 抗曬能力,更有效。
- 鄉民推:
- 千沛防曬(運動專用,防水不會太油)
訂閱:
文章 (Atom)