onClickListener does not work in fragment

前端 未结 5 1077
梦谈多话
梦谈多话 2020-11-28 12:59

I\'ve got some problems with the onClicklistener in the fragment. If I click on the button nothing happens at all. I get neither a message from the onClicklistener in Logcat

5条回答
  •  青春惊慌失措
    2020-11-28 13:39

    I think problem is here in your code

    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    { 
    .....
    ....
     //problem is here below line
     return inflater.inflate(R.layout.input_fgmt, container, false);
    }
    

    return your already inflated view

     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        { 
            View inputFragmentView = inflater.inflate(R.layout.input_fgmt, container, false);
        .....
        ....
    
         return inputFragmentView;
        }
    

提交回复
热议问题