Uncommon error progressbar

Asked

Viewed 51 times

0

I’m not understanding the error, I want to do a simple thing with Progressbar but it does not give 'void android.widget.Progressbar.setVisibility(int)' on a null Object Reference.

I know this error is because Progressbar was not started, but I actually started it this way. Still it gives error.

ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressBar3);
    progressBar.setVisibility(View.VISIBLE);
  • Just to be sure, this progressbar is being called where? Activity, Fragment, Dialog...? And if you can pass more of the code he’s in, it helps, too

  • There is no mystery in the code no, is in an Activity, I just wanted to see how the progressBar works, but is giving this error at the time of the visualization this progressibar is the infinite progressibar the cyclic. Actually I will use in an Ansytask but also gives the same error. I did the test with progressbar in my Activity and gives the same error.

  • I really wanted to use the progressibar as follows inside Ansytask in onPreExecute() show the progressibar and onPostExecute make it invisible. Remembering that it is only the cyclic.

  • Check this id R.id.progressBar3 with the layout, because the error is implying that the variable progressBar does not reference any object.

  • 2

    Good morning, @Stêniobarrosodemoraes! As simple as your problem may seem, only with these two lines of code you will not be able to solve it, because the answers will be just speculation. Edit your question and include the missing code

  • I am working with Mapview in Activity the issue of the error is that I can only start the progressibar after starting Mapview because it happens I do not know, so I put the progressiBar.setVisibility(View.VISIBLE) code; in the last line and it works.

  • Now when I try to use inside an Ansytask gives error even passing the parameters to the Ansytask constructor.

Show 2 more comments

1 answer

0

People already told me once it’s not working starting from scratch. I simply created another Copy and paste the code and it worked. My Victoria was buggered for some reason. I do not know what was simply Progressbar progressBar = findViewById(R.id.progressBar3; was returning null. When nothing is working properly go back to square one.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.