Parent -> Childcode
Activity -> ListItem對象
listitem 的動做須要依靠場景的某些屬性,又須要作到解耦,所以不能讓ListItem擁有Activity的對象。get
能夠這麼作。it
class ListItem { public interface Properties { boolean isTouchable(); String getName(); boolean isInSky(); } protected Properties mProperties; public void setProperties(Properties p) { mProperties = p; } @Click(R.id.fly) void fly() { if (p != null && p.isInSky()) { // do fly business } } } DemoActivity implements ListItem.Properties { public boolean isTouchable() { return true; } public getName() { return DemoActivity.class.getSimpleName(); } ... }