0

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 view) {}
1
  • but a breakpoint in the second line and launch the application in debug mode. See what it's null, (up or R.id.adultup1) and solve it using one of the answers below. I think you're getting the nullpointer in the up variable. Commented Oct 12, 2011 at 11:32

1 Answer 1

3

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

up = new Button[10];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.