Skip to content

Instantly share code, notes, and snippets.

@jimbray
Last active March 4, 2016 01:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimbray/c07d0e2d535194f383a0 to your computer and use it in GitHub Desktop.
Save jimbray/c07d0e2d535194f383a0 to your computer and use it in GitHub Desktop.
用泛型findViewById
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