findViewById returns null

后端 未结 4 2089
说谎
说谎 2020-11-22 09:59

I have code:

public class HelloWorld extends Activity {

private Button buttonOk;
private Button buttonCancel;

private OnClickListener buttonOkListener = ne         


        
4条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 10:52

    there is no problem with your codes, by right everything should work as per normal.

    The most common mistake of encountering null via findViewById() method is when you forgot to call setContentView() or called it for the wrong layout.

    I suggest cleaning your project and try again!!!!

提交回复
热议问题