Android通过代码获取布局
我在android的布局文件夹中有一个xml布局文件。 我想通过代码引用该文件来添加webviewAndroid通过代码获取布局,android,Android,我在android的布局文件夹中有一个xml布局文件。 我想通过代码引用该文件来添加webview 我该怎么做?您必须为布局提供一个id: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_h
我该怎么做?您必须为布局提供一个id:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
id="@+id/layout" >
</LinearLayout>
现在,您可以将您的网络视图添加到此布局。可能的重复项会使您的问题更加具体吗?
LinearLayout layout = (LinearLayout) findViewById(R.id.layout);