I'm new to Java and Android Studio. How can I use this line of code in my program? I can't use casting anymore in API 26.
public <T extends View > T findViewById(int id)
I'm new to Java and Android Studio. How can I use this line of code in my program? I can't use casting anymore in API 26.
public <T extends View > T findViewById(int id)
It's not an error - now you don't have to cast your views into the type(like casting to editText). If before you had to do :
editText = (EditText) findViewById(R.id.id);
You don't need it anymore and you can just do this :
editText = findViewById(R.id.id);
So if your compileSdk is at least 26, that means no need to typeCast the EditText. You can simply use:
EditText editText = findViewById(R.id.my_edittext);