0

I had a function in the main Activity that uses

val Nav: BottomNavigationView = findViewById(R.id.bottom_navigation)

because view was not necesary due to setContentView()

but now I moved this function to another class to be called with global companion Object So i need to pass it the view to activate it, since I have no View, just the setContentView()

How do I pass the view to this function?

Thank you

RodParedes
  • 378
  • 1
  • 2
  • 12
  • Can help to attach your code here as well? – Putra Nugraha Nov 11 '21 at 00:19
  • 1
    Why not pass the navigation view itself? Seems like a convoluted design for some other class to have to start digging into your Activity's view hierarchy and extract views. Separation of concerns. – Tenfour04 Nov 11 '21 at 00:46

1 Answers1

0

Could this be an alternative formation of your question? How to get Activity's view?

There an answer was given as

findViewById(android.R.id.content)

Worked for me (with Kotlin).

Guess you have managed to solve this issue already, but the question seemed too lonely to ignore. Perhaps this will save someone else’s time later.