Friday, 15 February 2013

android - WebView appears as plain white box after the second time it's been initialised -



android - WebView appears as plain white box after the second time it's been initialised -

edit: tl;dr: webview appears white box, though appear setting correctly, , indeed work first 2 times, fails subsequently)

edit: video showing problem in action...

i have next bit of code inflates view (which contains webview) xml defines it:

private void createcard(viewgroup cvframe, card card) { //... setup vairables... cvframe.cleardisappearingchildren(); cvframe.clearanimation(); seek { view cv = layoutinflater.from(getbasecontext()).inflate(r.layout.card_back_view, cvframe, true); cv.setbackgrounddrawable(drawable.createfromstream(mngr.open(deckname + "_card_back.png"), deckname)); textview suit = (textview)cv.findviewwithtag("card_back_suit"); //...setup text view suit, code works fine every time... webview title = (webview)cv.findviewwithtag("card_back_title"); //this webview doesn't appear 1 appears on screen (i can alter settings till i'm bluish in face, no effect) if (title != null) { title.setbackgroundcolor(0x00000000); title.loaddata(titletext, "text/html", "utf-8"); } else { log.e("cardview", "error can't find title webview"); } } grab (ioexception e) { log.e("cardview", "error making cards: ", e); } }

when method called part of oncreate method in activity, webview contains right code, , suitably transparent.

i have gesture listener replaces contents of viewgroup different content (it animates top card off left, replaces contents of top card card 2, puts top card back, replaces card 2 card 3)

//gesture listener event viewgroup cvframe = (viewgroup)findviewbyid(r.id.firstcard); cardloc++ cvframe.startanimation(slideleft);

(onanimationend code)

public void onanimationend(animation animation) { if (animation == slideleft) { viewgroup cvframeoldfront = (viewgroup)findviewbyid(r.id.firstcard); viewgroup cvframenewfront = (viewgroup)findviewbyid(r.id.secondcard); createcard(cvframeoldfront, cards.get((cardloc)%cards.size())); createcard(cvframenewfront, cards.get((cardloc+1)%cards.size())); translateanimation slideback = new translateanimation(0,0,0,0); slideback.setduration(1); slideback.setfillafter(true); cvframeoldfront.startanimation(slideback); } }

when animation has happened , replace contents of cards, textview suit replaced fine , code passes through code replace webview contents, reason end white rectangle size , shape of webview, no content, no transparency.

if alter webview textview, it's contents replaced fine, it's issue occurs webview command :s

can tell me why / suggest fix?

it turns out webview doesn't cleared downwards when using layoutinflater replace contents of viewgroup. other controls seem removed (or @ to the lowest degree findviewwithtag() returns right reference every other control). i've added in line cvframe.removeallviews() before layoutinflater it's stuff , fixed issue. if has improve explanation i'll throw points way otherwise go ether...

android android-webview layout-inflater

No comments:

Post a Comment