您的位置:首页 > 移动开发 > Android开发

android findViewById(...)的抽取

2016-02-02 11:06 543 查看

之前看到的一片博客,然后就保存下来了。哪一篇忘了

/**
* 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);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: