Android ImageButton worked well in Activity. It doesn't work in Fragment
问题 I'm trying to convert a layout so that it will include fragments. One of the views is an ImageButton that has a listener. The code worked fine as an Activity but makes trouble as a Fragment... First problem was that I couldn't use findViewById, but I was able to find the answer for that here and fixed it with getView(). I can't find an answer to the second problem... after I declared: ImageButton camBt = (ImageButton)getView().findViewById(R.id.button1); I want to set an on click listener: