Alt+Shift+ Up, Down, Right, Left
Ctrl+Shift+ Up, Down, Right, Left
Thứ Tư, 6 tháng 6, 2012
Using Application Class
Yamba app,
Chỉ lúc click Update mới gọi đến Application obj, trong khi App obj phải watcher prefs change, vậy App obj được tạo ngay khi android app oncreate hay là tạo lúc được gọi.
Twitter.Status status = ((YambaApplication1)getApplication()).getTwitter().updateStatus(statuses[0]);
Chỉ lúc click Update mới gọi đến Application obj, trong khi App obj phải watcher prefs change, vậy App obj được tạo ngay khi android app oncreate hay là tạo lúc được gọi.
Twitter.Status status = ((YambaApplication1)getApplication()).getTwitter().updateStatus(statuses[0]);
Two ways of addTextChangedListener
2 cách này khác nhau ntn?
07/06/2012:
Service, Activity, Broadcast receiver chạy chung một thread hay khác nhau, mỗi khi tạo 1 obj là tạo 1 thread ah, làm sao để biết(thread id - DDMS)?
edtInputA.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// TODO Auto-generated method stub
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
});
Và:
editText.addTextChangedListener(this);
07/06/2012:
Service, Activity, Broadcast receiver chạy chung một thread hay khác nhau, mỗi khi tạo 1 obj là tạo 1 thread ah, làm sao để biết(thread id - DDMS)?
Thứ Ba, 5 tháng 6, 2012
PreferenceActivity ???
Công nhận là nhanh và tiện, nhưng có cần thiết dùng tới ko, trong khi có thể self-make 1 cái đơn giản hơn. Hay khó ở chỗ làm một cái PreferenceChangedListener ???
Một cái nữa vẫn còn mơ hồ là khi kế thừa nhiều cái thì lúc này hình dạng của obj sẽ như thế nào nhỉ, 1 thăg obj = tất cả các cha cộng lại ?!
Có lẽ vì lý do store these preferences nên chắc phải dùng thư viện có sẵn:
Một cái nữa vẫn còn mơ hồ là khi kế thừa nhiều cái thì lúc này hình dạng của obj sẽ như thế nào nhỉ, 1 thăg obj = tất cả các cha cộng lại ?!
Có lẽ vì lý do store these preferences nên chắc phải dùng thư viện có sẵn:
So, where does the device store these preferences? How secure is my username and
password? To answer that, we need to look at how the Android filesystem is organized.
Thứ Hai, 4 tháng 6, 2012
Pass optional params with varargs: String... names
Varargs (introduced in Java SE 5) allows you to pass 0, 1, or more
params to a method's vararg param. This reduces the need for
overloading methods that do the similar things. For example,
org.apache.commons.lang.StringUtils is in commons-lang-2.4.jar. Running this example gives the following output:
package javahowto;
import org.apache.commons.lang.StringUtils;
public class HelloWorld {
public static void main(String[] args) {
hello();
hello("World");
hello("Santa", "Bye");
final String[] names = {"John", "Joe"};
hello(names);
}
public static void hello(String... names) {
final String defaultName = "Duke";
String msg = "Hello, ";
msg += ((names.length == 0) ? defaultName : StringUtils.join(names, ", "));
System.out.println(msg);
}
}
org.apache.commons.lang.StringUtils is in commons-lang-2.4.jar. Running this example gives the following output:
Hello, Duke Hello, World Hello, Santa, Bye Hello, John, Joe BUILD SUCCESSFUL (total time: 0 seconds)http://javahowto.blogspot.com/2008/12/pass-optional-params-with-varargs.html
Thứ Sáu, 1 tháng 6, 2012
need parameter or not for method called by onClick
XML file: Button - android:onClick="backToFirst"
Method in java file: public void backToFirst()
Without parameter:
Oh, i see, it need a View =)
How about private method or protected or the return value???
Work: return value
NOT Work: private, protected
Method in java file: public void backToFirst()
Without parameter:
06-01 22:54:26.811: E/AndroidRuntime(421): java.lang.IllegalStateException: Could not find a method backToFirst(View) in the activity class ad01.qmn.session8.ResultActivity for onClick handler on view class android.widget.Button with id 'btnBack'
Oh, i see, it need a View =)
How about private method or protected or the return value???
Work: return value
NOT Work: private, protected
Increase Eclipse's Memory Settings
eclipse.ini
-Xms40m
-Xmx256m
-XX:MaxPermSize=256m
Recommended settings for Android development:-Xms128m
-Xmx512m
-XX:MaxPermSize=256m
These settings set Eclipse's minimum Java heap size to 128MB, set the maximum Java heap size to 512MB, and keep the maximum permanent generation size at the default of 256MB.
http://source.android.com/source/using-eclipse.html
Đăng ký:
Bài đăng (Atom)