Last active
March 4, 2016 01:26
-
-
Save jimbray/c07d0e2d535194f383a0 to your computer and use it in GitHub Desktop.
用泛型findViewById
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public <T extends View> T $(int id) { | |
return (T) super.findViewById(id); | |
} | |
public <T extends View> T $(View view, int id) { | |
return (T) view.findViewById(id); | |
} | |
//跳转Activity | |
public void openActivity (Class<?> activity) { | |
startActivity(new Intent(this, activity)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment