If you want to access any view, you have view object to access it.
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.frag1,container,false);
btn = (Button)view.findViewById(R.id.button);
return view;
}
solved Cannot resolve method ‘findViewById(int)’ in Fragment of ViewPager [duplicate]