Thứ Năm, 1 tháng 11, 2012
Thứ Năm, 13 tháng 9, 2012
đổi giá trị 2 biến
int a = 9; int b = 1; a ^= b; b ^= a; a ^= b;//output: a = 1, b =9 Không hiểu đoạn code này, mình còn nhiều thứ phải học quá
Thứ Sáu, 31 tháng 8, 2012
TabWidget note 1
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/tab_bg_selector"
android:gravity="center"
android:orientation="vertical" >
<TextView android:id="@+id/tv_tab_label"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="test Tab"
android:textColor="@drawable/tab_text_selector" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="test height"/>
</LinearLayout>
whatever number child views in LinearLayout, tab indicator only use the first child
and height in LinearLayout don't work, why?
and width, height in TextView don't work too, just work with specific height, ex: 60dip
How's TabSpec.setIndicator work?
padding work with LinearLayout, chung' to? la` tab indicator khong co ignore parent layout
Thứ Tư, 6 tháng 6, 2012
Shortcuts for selections in eclipse
Alt+Shift+ Up, Down, Right, Left
Ctrl+Shift+ Up, Down, Right, Left
Ctrl+Shift+ Up, Down, Right, Left
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
Thứ Tư, 30 tháng 5, 2012
Field Naming Conventions for Android
- Non-public, non-static field names start with m.
- Static field names start with s.
- Other fields start with a lower case letter.
- Public static final fields (constants) are ALL_CAPS_WITH_UNDERSCORES.
public class MyClass {
public static final int SOME_CONSTANT = 42;
public int publicField;
private static MyClass sSingleton;
int mPackagePrivate;
private int mPrivate;
protected int mProtected;
}
http://source.android.com/source/code-style.html
Thứ Hai, 28 tháng 5, 2012
Package java.qmn.thread can't find main class ???
Đặt package name là java.qmn.thread -> compile báo là không tìm thấy main class
Đổi thành notjava.qmn.thread thì compile được, nghĩa là compiler package mình ngang thư mục với package java có sẵn, học thêm một cái mới.
Đổi thành notjava.qmn.thread thì compile được, nghĩa là compiler package mình ngang thư mục với package java có sẵn, học thêm một cái mới.
Thứ Năm, 12 tháng 1, 2012
Cách làm giảm ping counter strike 1.6 (cs 1.6) trên windows 7
Đầu tiên test xem có đúng bệnh không, vào Device Manager disable all sound device đi, rồi vào chơi game, nếu giảm lag thì đúng bệnh rồi đó.
Download and run: NetworkThrottling.reg
Nguồn: http://www.sevenforums.com/gaming/31980-lag-online-games-windows-7-a.html#post331641
http://forum.digitalpowered.net/index.php?showtopic=40886
Download and run: NetworkThrottling.reg
Nguồn: http://www.sevenforums.com/gaming/31980-lag-online-games-windows-7-a.html#post331641
http://forum.digitalpowered.net/index.php?showtopic=40886
Đăng ký:
Bài đăng (Atom)