question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

findViewById, causing missing adapter error

See original GitHub issue

When I execute DotsIndicator dotsIndicator = findViewById(R.id.dots_indicator_view_pager_insights);, getting an error message straight away

DotsIndicator: You have to set an adapter to the view pager before !

I do set the adapter right after the findViewById, shouldn’t the message appear later on, if no adapter has yet been set?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Selidinokcommented, Apr 5, 2019

I have similar issue. DotsIndicator call refreshDots() inside init(AttributeSet attrs) method when class initialize. So even viewPager = null at that moment.

0reactions
tommybuonomocommented, Apr 2, 2019

Sorry but the code is clear:

if (viewPager != null && viewPager.getAdapter() != null) {
      ...
    } else {
      Log.e(DotsIndicator.class.getSimpleName(), "You have to set an adapter to the view pager before !");
    }

You have an error somewhere in your code.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Not able to "findViewById" in Kotlin. Getting error "Type ...
Try something like: val recyclerView = findViewById<RecyclerView>(R.id.recycler_view). You can use Kotlin Android Extensions too for that.
Read more >
I can't find why these errors are showing, anyone help?
there are errors in this bit of code, I have added the line numbers at the start. public class ViewHolder extends RecyclerView.ViewHolder {...
Read more >
Evolution of Finding Views by ID in Android - Wajahat Karim
Obviously, the first one is the findViewById() method. Introduced in the API level 1, this requires an ID and returns a View object....
Read more >
Getting NullPointerException on viewPager.setAdapter
One possible root cause for your problem would be that fact that the line: viewPager = (ViewPager) findViewById(R ...
Read more >
Applying Data Binding for Views | CodePath Android Cliffnotes
Make sure that all your XML files with data binding have their errors fully resolved and the files are saved. Then be sure...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found