How to specify id when uses include in layout xml file

前端 未结 11 2562
挽巷
挽巷 2020-12-02 08:55

In my layout xml file, I have included other layout xml file (each with a different android id).



        
11条回答
  •  遥遥无期
    2020-12-02 09:45

    In a case of using find the id of by using an instance of inflated view or else it will return null.

    public class ViewHolder extends RecyclerView.ViewHolder {
    
            private mTextView;
    
            public ViewHolder(View view) {
                super(view);
                View include_1 = view.findViewById(R.id.include_1);
                mTextView = (TextView) include_1.findViewById(R.id.text_id);
            }
        }
    

提交回复
热议问题