Skip to content

Instantly share code, notes, and snippets.

@ppareit
Created December 26, 2016 22:22
Show Gist options
  • Select an option

  • Save ppareit/9daecd00a8b2891fb5ea8e70b56dce0f to your computer and use it in GitHub Desktop.

Select an option

Save ppareit/9daecd00a8b2891fb5ea8e70b56dce0f to your computer and use it in GitHub Desktop.
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