メインビューにビューを追加したい....
私のmain.xmlファイル...
<LinearLayout
android:id="@+id/dynamicview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.28"
android:gravity="center_vertical"
android:orientation="vertical" >
</LinearLayout>
別のレイアウト ファイル コール complete.xml があります。
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
このWebビューをlinearlayoutに追加したい....つまり、Webビューをメインアクティビティにインフレートしたい...
私は次の方法を使用しました...
LinearLayout dynamic=(LinearLayout)findViewById(R.id.dynamicview);
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = (FrameLayout) inflater.inflate(R.layout.complete, null);
v.setBackgroundColor(Color.GREEN);
v.getRootView();
dynamic.addView(v);
v.setVisibility(View.VISIBLE);
しかし、これは機能しません。これが正しければ、色を変更する必要があります...しかし、何も起こりませんでした。plsは私を助けて..私はこれで立ち往生しています...
ありがとう