One of the least commented on, but far-reaching changes in Android, is a new signature for the ubiquitous findViewByIdI() method. It’s used by all Android developers, and has remained unchanged since the introduction of Android. If you wanted to save a view reference with specific type, such as Button or TextView, you’d have to include casting syntax. But with the new generic declaration of the method’s return type, the casting expression is no longer needed.
- [Instructor] One of the least commented-on…but far-reaching changes in Android was a new signature…for the ubiquitous findViewById method.…This method is used by just about all Android developers…to get references to view objects in layouts.…Traditionally, when you call findViewById,…it returns a view object.…If you want to cast it as a specific type,…you have to including Java-casting syntax.…But in Android 8, API level 26, a change was made…to the signature of the findViewById method.…
This method now uses generic typing.…Instead of returning a standard view object,…it returns a type that extends view, and that means…that you can return any specific concrete type…without having to explicitly cast the result.…In this application, which I've upgraded to use…Android 8.1, API 27, I see the results in Android Studio.…My casting syntaxt is now shown in dim characters,…and if I move the cursor over,…it tells me that the casting is redundant.…
Now, I can fix these one at a time.…I'll simply click into the type and press alt enter,…
Skill Level Intermediate
Q: Why can't I earn a Certificate of Completion for this course?
A: We publish a new tutorial or tutorials for this course on a regular basis. We are unable to offer a Certificate of Completion because it is an ever-evolving course that is not designed to be completed. Check back often for new movies.
Android App Development: Communicating with the Userwith Joe Marini1h 12m Intermediate
Building Android Apps with Cloud Serviceswith Albert Lo2h 37m Intermediate
Android App Development: Data Persistence Librarieswith Annyce Davis4h 52m Intermediate
New This Week:
1. Android Development Tips Weekly
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.