2

メインビューにビューを追加したい....

私の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は私を助けて..私はこれで立ち往生しています...

ありがとう

4

1 に答える 1

0

これを試して:

LinearLayout dynamic=(LinearLayout)findViewById(R.id.dynamicview);
LayoutInflater inflater = (LayoutInflater)    getSystemService(Context.LAYOUT_INFLATER_SERVICE);

View v = (FrameLayout) inflater.inflate(R.layout.complete, null);

WebView wv = (WebView)v.findViewById(R.id.webView1);
wv.setBackgroundColor(Color.GREEN);
        v.getRootView();
        dynamic.addView(v);
        v.setVisibility(View.VISIBLE);

FrameLayoutで塗りつぶされたの色を変更しようとしていたWebViewため、緑色は表示されません。代わりに、の色を変更する必要がありますWebView

于 2013-08-11T07:44:14.900 に答える