Last active
December 26, 2016 13:34
-
-
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
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
T findViewByIdWithoutCasting(int id) { | |
T item = CS.as(getActivity().findViewById(id)); | |
return item; | |
} |
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
Button button = findViewByIdWithoutCasting(R.id.button); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
T item = CS.as(getActivity().findViewById(id));
where is the CS object coming from ?
can i see example for it ?