findViewById within fragment

前端 未结 5 1523
轮回少年
轮回少年 2020-12-13 19:14

Is there any way to find a view by id within the scope of a fragment? I\'m using a series of fragments to render a specialized list. The fragments are loaded from a layout

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-13 19:57

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

提交回复
热议问题