Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/204.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android WebView没有';不要出现在线性布局上_Android_Webview_Android Linearlayout - Fatal编程技术网

Android WebView没有';不要出现在线性布局上

Android WebView没有';不要出现在线性布局上,android,webview,android-linearlayout,Android,Webview,Android Linearlayout,我在以线性布局显示WebView时遇到问题。在我的代码中,我可以将WebView视图更改为TextView,一切都很好。我想展示11个包含谷歌搜索结果的WebView面板 My MainActivity.java protected void onCreate(Bundle savedInstanceState) { ... LinearLayout relLay = (LinearLayout) findViewById(R.id.main_relLay); LayoutInflater in

我在以线性布局显示WebView时遇到问题。在我的代码中,我可以将WebView视图更改为TextView,一切都很好。我想展示11个包含谷歌搜索结果的WebView面板

My MainActivity.java

protected void onCreate(Bundle savedInstanceState) {
...
LinearLayout relLay = (LinearLayout) findViewById(R.id.main_relLay);
LayoutInflater inflater = (LayoutInflater) getApplication()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

for(int i=1; i<11; i++){
    View v_child = inflater.inflate(R.layout.row, null);
    relLay.addView(v_child);
    String link = "https://www.google.com/search?q=" + i;

    WebView web_view = (WebView) v_child.findViewById(R.id.row_webView);  
    web_view.loadUrl(message);
}
...
创建时受保护的void(Bundle savedInstanceState){
...
LinearLayout relLay=(LinearLayout)findViewById(R.id.main_relLay);
LayoutFlater充气器=(LayoutFlater)getApplication()
.getSystemService(上下文布局\充气机\服务);

对于(int i=1;i默认情况下,您保持了
WebView
visibility的状态,这就是它不显示的原因

只需从xml文件的
WebView
中删除行
android:visibility=“gone”

 <WebView
        android:id="@+id/row_webView"
        android:background="#323232"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        > //Remove visibility line.
    </WebView>  
//删除可见性线。
修改您的row.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
        <WebView
            android:id="@+id/row_webView"
            android:background="#323232"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
 >
        </WebView>
</LinearLayout>

自从android:visibility=“gone”…@Volz查看我的答案。
 <WebView
        android:id="@+id/row_webView"
        android:background="#323232"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        > //Remove visibility line.
    </WebView>  
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
        <WebView
            android:id="@+id/row_webView"
            android:background="#323232"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
 >
        </WebView>
</LinearLayout>