I wrote a method to get views by id in Android like this: E.g.
Button button = <Button>find(R.id.someId);
There is actually no need for < Button>. This is the method I wrote:
protected <T extends View> T find(int id){
return (T) findViewById(id);
}
It works great, but the warning "Unchecked cast" bothers me. How could I get rid if it? Is this method save? I was inspired by Kotlin so much, that I wanted to create this nice little method to make the code prettier.