1.拷贝Android项目时,不要丢失隐藏文件.project,.classpath,.setting
2.类名、变量名、方法名见名知意,取名原则是大众普遍接受的Java命名规范和Objective-C的命名规范
3.JavaBean重写toString方法,输出我们需要输出的属性信息,至于ios重写description方法
public class Address {
private int id;
private String name;
private int parent_id;
private int type;
private String zip;
...
@Override
public String toString() {
return "Address [ id = " + id + ", "
+ "name = " + name + ", "
+ "parent_id = " + parent_id + ", "
+ "type = " + type + ", "
+ "zip = " + zip;
}
}
4.自定义Intent的Action命名规则为
a.调用名称为ACTION+动作名称/其他名称(大写),单词之间用下划线连接(_)如:ACTION_MAIN
b.Action名称为项目包名+"intent.action"+动作名称/其他名称(大写),单词之间用点号连接(.)如:"com.xxx.xxx.intent.action.MAIN"
c.放在常量集合的接口中
public interface CommonDefine {
// 自定义IntentAction.ACTION_MAIN
interface IntentAction {
public static final String ACTION_MAIN = "com.xxx.xxx.intent.action.MAIN";
}
// 系统的Intent.ACTION_MAIN
/**
* Activity Action: Start as a main entry point, does not expect to receive
* data.
*
* Input: nothing
*
* Output: nothing
*/
// @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
// public static final String ACTION_MAIN = "android.intent.action.MAIN";
/**
* Activity Action: Pick an item from the data, returning what was selected.
*
* Input: {@link #getData} is URI containing a directory of data
* (vnd.android.cursor.dir/*) from which to pick an item.
*
* Output: The URI of the item that was picked.
*/
// @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
// public static final String ACTION_PICK = "android.intent.action.PICK";
}
5.自定义Intent的Extra命名规则为
a.调用名称为EXTRA+功能名称/JavaBean的类名/其他名称(大写)(SHORTCUT/ARTICLE)+功能需要传递的内容/JavaBean的属性名称/其他名称(大写)(NAME/TITLE),单词之间用下划线连接(_)如:EXTRA_SHORTCUT_NAME, EXTRA_ARTICLE_TITLE
b.EXTRA名称为项目包名+"intent.extra"+功能名称/JavaBean的类名/或其他名称(shortcut/acticle)+功能需要传递的内容/JavaBean的属性名称/其他名称(大写)(NAME/TITLE),单词之间用点号连接(.),如:"com.xxx.xxx.intent.extra.shortcut.NAME","com.xxx.xxx.intent.extra.article.TITLE",
c.放在常量集合的接口中
public interface CommonDefine {
// 自定义IntentExtra.EXTRA_SHORTCUT_NAME
interface IntentExtra {
public static final String EXTRA_SHORTCUT_NAME = "com.xxx.xxx.intent.extra.shortcut.NAME";
}
// 系统的Intent.EXTRA_SHORTCUT_NAME
/**
* The name of the extra used to define the name of a shortcut.
*
* @see #ACTION_CREATE_SHORTCUT
*/
// public static final String EXTRA_SHORTCUT_NAME =
// "android.intent.extra.shortcut.NAME";
/**
* The name of the extra used to define the icon, as a Bitmap, of a
* shortcut.
*
* @see #ACTION_CREATE_SHORTCUT
*/
// public static final String EXTRA_SHORTCUT_ICON =
// "android.intent.extra.shortcut.ICON";
}
6.自定义SharedPreferences中的Key的命名规则
a.调用名称为KEY+关键字名,单词之间用下划线连接(_)如:KEY_PRODUCT
b.Key名称为项目包名+"pref.key"+关键字名(大写),单词之间用点号连接(.)如:"com.xxx.xxx.pref.key.PRODUCT"
c.放在常量集合的接口中
public interface CommonDefine {
// 自定义PrefKey.KEY_PRODUCT
interface PrefKey {
public static final String KEY_PRODUCT = "com.xxx.xxx.pref.key.PRODUCT";
public static final String KEY_ARTICLE = "com.xxx.xxx.pref.key.ARTICLE";
}
}
7.自定义startActivityForResult中的RequestCode
Intent intent = new Intent();
intent.setAction(IntentAction.ACTION_FROM_