こんにちは、新しい Android 3.0 adwhirl を動作させようとしていますが、苦労しています。
私のxmlには次のものがあります:
私のクラスで
...
setContentView(R.layout.main);
//Add Whirl
AdWhirlManager.setConfigExpireTimeout(1000 * 60 * 5);
AdWhirlTargeting.setTestMode(false);
AdWhirlLayout adWhirlLayout = (AdWhirlLayout)findViewById(R.id.adwhirl_layout);
TextView textView = new TextView(this);
RelativeLayout.LayoutParams layoutParams = new
RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
int diWidth = 320;
int diHeight = 52;
int density = (int) getResources().getDisplayMetrics().density;
adWhirlLayout.setAdWhirlInterface(this);
adWhirlLayout.setMaxWidth((int)(diWidth * density));
adWhirlLayout.setMaxHeight((int)(diHeight * density));
layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
textView.setText("Below AdWhirlLayout");
LinearLayout layout = (LinearLayout)findViewById(R.id.layout_main);
layout.setGravity(Gravity.CENTER_HORIZONTAL);
layout.addView(adWhirlLayout, layoutParams);
layout.addView(textView, layoutParams);
layout.invalidate();
...
しかし、私がそれを実行すると、
指定された子にはすでに親がいます。最初に子の親で removeView() を呼び出す必要があります。
おそらく単純なレイアウトの問題であることはわかっていますが、解決策がわかりません。助けていただければ幸いです。
友よありがとう。