When you inflate a view, it is usually recommended that you instantiate a specific type of view that you are inflating. In this case, you pump up the TextView . Since TextView continues from View , the compiler will not complain about it, but when you try to use View as a TextView , your application will crash.
// create a new view TextView v = (TextView) LayoutInflater.from(parent.getContext()) .inflate(R.layout.my_text_view, parent, false);
Change View to TextView .
source share