Android O casting to findViewById not needed anymore? [duplicate]

The method signature changed as you noticed and now it looks like:

public <T extends View> T findViewById(int id);

compared to the old (pre SDK 26) one:

public View findViewById(int id);

so as long as you use SDK 26 (or newer) to compile your project you can safely remove the casting from your code as you will be using new findViewById() which no longer requires it.

so having a lower minSdk than 26 will not cause an issue ?

No, neither minSdk nor targetSdk really matter. What matters is compileSdk which must be 26 or higher.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)