Created
December 26, 2016 22:22
-
-
Save ppareit/9daecd00a8b2891fb5ea8e70b56dce0f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| package be.ppareit.android; | |
| import android.app.Activity; | |
| import android.view.View; | |
| /** | |
| * Instead of calling | |
| * RadioButton radioButton = (RadioButton) findViewById(R.id.radio_toggle); | |
| * You can call | |
| * RadioButton radioButton = findView(this, R.id.radio_toggle); | |
| */ | |
| public class ViewUtil { | |
| public static <T extends View> T findView(Activity activity, int id) { | |
| return (T) activity.findViewById(id); | |
| } | |
| public static <T extends View> T findView(View view, int id) { | |
| return (T) view.findViewById(id); | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment