Starting with API 26, findViewById
uses inference for its return type, so you no longer have to cast.
Old definition:
View findViewById(int id)
New definition:
<T extends View> T findViewById(int id)
So if your compileSdk
is at least 26, it means that you can make use of this 🙂
More Related Contents:
- Null pointer Exception – findViewById()
- findViewById in Fragment
- Why does my Android app crash with a NullPointerException when initializing a variable with findViewById(R.id.******) at the beginning of the class?
- Can not find a View with findViewById()
- How can I assign an ID to a view programmatically?
- Android: How can I Convert String to Date?
- findViewById() returns null for Views in a Dialog
- Kotlin Android View Binding: findViewById vs Butterknife vs Kotlin Android Extension
- How can you make a custom keyboard in Android? [closed]
- Android Firebase DynamiteModule: Failed to load module descriptor
- Getting “SocketException : Connection reset by peer” in Android
- Complete Working Sample of the Gmail Three-Fragment Animation Scenario?
- Adding Google Play services version to your app’s manifest?
- Android Studio – How Can I Make an AVD With ARM Instead of HAXM?
- Prevent screen rotation on Android
- Load dimension value from res/values/dimension.xml from source code
- Getting the dimensions of the soft keyboard
- getActionBar() returns Null (AppCompat-v7 21)
- What is the equivalent of ActionBar in earlier sdk versions? [closed]
- how to customize listview row android
- Android Retrofit – onProgressUpdate for showing Progress Notification
- Android ‘debuggable’ default value
- Android: Total height of ScrollView
- How to import a .aar file into Android Studio 1.1.0 and use it in my code
- How to count app usage time while app is on foreground?
- Overriding the power button in Android
- how to make my viewpager swipe from right to left
- Error after updating the Android.Support Library v7 AppCompat to the 21.0.3 version
- java.lang.illegalstateexception could not find a method (view) in the activity class android fragment
- How to use setOutlineProvider instead of setOutline in Lollipop