1

I recently integrate MoPub for showing the advertisement of my enterprise. So I have added a part of xml into my main.xml

 <com.mopub.mobileads.MoPubView
        android:id="@+id/adview"
        android:layout_width="fill_parent"
        android:layout_height="50dp" />

And for download image of advertisement,

private static class LoadHtmlAdTaskResult extends LoadUrlTaskResult {
    protected String mData;

    private LoadHtmlAdTaskResult(AdView adView, String data) {
        super(adView);
        mData = data;
    }

    public void execute() {
        if (mData == null)
            return;

        AdView adView = mWeakAdView.get();
        if (adView == null || adView.isDestroyed())
            return;

        adView.mResponseString = mData;
        Log.i(TAG, "LoadHtmlAdTaskResult"); 
        //String contain html tags with images      
        String source =
    "<img src='http://banner.testadvertisement.com/campaign/12563254'>";
        adView.loadDataWithBaseURL("http://www.adserverpub.com",
            source,"text/html","UTF-8","about:blank");
    }

But The image doesn't show up and I always get this error in my catlog "can't get the viewwidth after the first layout".

Does anyone have encountered this problem?

I have no idea where this error come from? Thank you all.

4

0 回答 0