Andorid之Annotation框架初使用(七)

Save Instance State:
程序保留Activity的实例状态 , 在onSaveInstanceState(Bundle)被系统调用的时候自动保存 , onCreate(Bundle)被系统调用会重新修复。

@EActivity
public class MyActivity extends Activity {
    @InstanceState
    int someId;
    @InstanceState
    MySerializableBean bean;
}


设置没有Title:

@NoTitle
public class MyActivity extends Activity {}


设置全屏:

@Fullscreen
public class MyActivity extends Activity {}


设置自定义的Title:

@CustomTitle(R.layout.custom_title)
public class MyActivity extends Activity {}


OnActivityResult:

@OnActivityResult(REQUEST_CODE)
 void onResult(int resultCode, Intent data) {
 }
 @OnActivityResult(REQUEST_CODE)
 void onResult(int resultCode) {
 }
 @OnActivityResult(ANOTHER_REQUEST_CODE)
 void onResult(Intent data) {
 }
 @OnActivityResult(ANOTHER_REQUEST_CODE)
 void onResult() {
 }


Ormlite :
@OrmLiteDao( help= android.database.sqlite.SQLiteOpenHelper类的实例 , model= 模型类 )

@EActivity
public class MyActivity extends Activity {
    // UserDao is a Dao<User, Long>
    @OrmLiteDao(helper = DatabaseHelper.class, model = User.class)
    UserDao userDao;
    @OrmLiteDao(helper = DatabaseHelper.class, model = Car.class)
    Dao<Car, Long> carDao;
}

你可能感兴趣的:(annotation)