findViewById within fragment findViewById within fragment android android

findViewById within fragment


private View myFragmentView;@Overridepublic View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {    myFragmentView = inflater.inflate(R.layout.myLayoutId, container, false);    myView = myFragmentView.findViewById(R.id.myIdTag)    return myFragmentView;}


From inside the Fragment:

getView().findViewById(R.id.your_view);

From the enclosing Activity:

getFragmentManager().findFragmentByTag("YourFragmentTag").getView().findViewById(R.id.your_view);

or

getFragmentManager().findFragmentById(R.id.your_fragment).getView().findViewById(R.id.your_view);


You can do it by getView().findViewById()