findViewById возвращает NULL при использовании фрагмента

Вы должны inflate макет фрагмента nullreferenceexception в методе onCreateView метода Fragment, тогда activity вы можете просто получить fragment доступ к его элементам с activity помощью findViewById на вашем Activity.

В этом android-activity примере мой макет фрагмента android-application - LinearLayout, поэтому я android-ui привожу результат inflate в LinearLayout.

    public class FrgResults extends Fragment 
    {
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) 
        {
            //some code
            LinearLayout ll = (LinearLayout)inflater.inflate(R.layout.frg_result, container, false);
            //some code
            return ll;
        }
    }

android

android-activity

nullreferenceexception

fragment

2022-10-03T22:32:54+00:00