Since type parameters are actually cleared in bytecode, you can use the class name in XML as if it were not parameterized, and then passed it to the correct parameterized type in java code.
consider the class:
public class CustomViewFlipper<T extends View> extends ViewFlipper {
and in your xml action layout:
<view class="com.some.package.CustomViewFlipper" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/customFlipper"/>
then in your activity:
@Override protected void onCreate(Bundle savedInstanceState) {
Tomasz gawel
source share