开发者

Android: Custom view fails to instantiate

I am trying to add Smaato to my app to monotize it. I have been following the developers guide but I keep getting the error that my custom view for the banner isn't being instantiated. I have the custom view wrapped in a relative layout:

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_alignParentBottom="true" android:id="@+id/adcontainer"
    android:layout_height="50dip" android:background="#666">
        <com.smaato.SOMA.SOMABanner android:id="@+id/BannerView"
            android:layout_开发者_JAVA技巧width="fill_parent" android:layout_height="50dip" />
    </RelativeLayout>

I follow the other steps, but no where does it seem to show how to instantiate the view. Any ideas how to do this?


com.smaato.SOMA.SOMABanner must be a public class with a constructor public SOMABanner(Context context, AttributeSet attributeSet).


Although this wasn't the problem here I had a similar issue because I wasn't passing the AttributeSet to my custom view and eclipse couldn't find the appropriate constructor.

Whatever your class is make sure it has a constructor that matches the signature:

public MyClass(Context context, AttributeSet attributeSet){}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜