开发者

null pointer exception in button declaration

开发者 https://www.devze.com 2023-04-12 23:35 出处:网络
in this line am getting NullPointerException can any one help me to fix this Button up[]; up[0] = (Button) findViewById(R.id.adultup1);

in this line am getting NullPointerException can any one help me to fix this

Button up[]; 
up[0] = (Button) findViewById(R.id.adultup1);
up[0].setOnClickListener(new View.OnClickListener() {
    public void onClick(View v开发者_Go百科iew) {}


You need to allocate the Button array, e.g.

up = new Button[10];
0

精彩评论

暂无评论...
验证码 换一张
取 消