之前看到的一片博客,然后就保存下来了。哪一篇忘了
/**
* view utils
* @author loader
*/
public class ViewUtils {
/**
* activity.findViewById()
* @param context
* @param id
* @return
*/
public static <T extends View> T f(Activity context, int id) {
return (T) context.findViewById(id);
}
/**
* rootView.findViewById()
* @param rootView
* @param id
* @return
*/
public static <T extends View> T f(View rootView, int id) {
return (T) rootView.findViewById(id);
}
}