Reputation: 567
I have created a method and an inner class in fragment. However outer class method is inaccessible in inner class of Fragment? How to call outer class method or member in inner class of fragment. Below is my code:
class BlankFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
mOrientationListener = OrientationChangeListener(requireContext())
}
fun rotateUI(orientation: Int){
/// something
}
/**
* This callback returns rotation angle of the phone, to make it return orientation angles enable it on onStart and disable it onPause
*/
private var mOrientationListener: OrientationChangeListener? = null
internal class OrientationChangeListener (context: Context?) : OrientationEventListener(context) {
/** portrait
* (0, 359)
*
* (270) (90)
* (land) (land)
*/
override fun onOrientationChanged(orientation: Int) {
// this method is inaccessible
//rotateUI(orientation)
}
}}
Upvotes: 1
Views: 595
Reputation: 71
For inner class the keyword should be inner not internal and then you can use this to access the method like :-
[email protected]
Upvotes: 2