Skip to content

Instantly share code, notes, and snippets.

@SimoneLocatelli
Last active December 26, 2016 13:34
Show Gist options
  • Save SimoneLocatelli/8031881 to your computer and use it in GitHub Desktop.
Save SimoneLocatelli/8031881 to your computer and use it in GitHub Desktop.
Android code snippet to avoid casting when call findViewById method http://jabtw.blogspot.it/2013/12/android-find-view-without-casting.html
T findViewByIdWithoutCasting(int id) {
T item = CS.as(getActivity().findViewById(id));
return item;
}
Button button = findViewByIdWithoutCasting(R.id.button);
@ahmadmust8
Copy link

ahmadmust8 commented Dec 26, 2016

T item = CS.as(getActivity().findViewById(id));
where is the CS object coming from ?
can i see example for it ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment