Error:(18, 56) error: cannot find symbol variable webView

后端 未结 3 1396
粉色の甜心
粉色の甜心 2021-01-29 02:01

I get this error Error:(18, 56) error: cannot find symbol variable webView

Here is code of Activity

package com.example.luk         


        
相关标签:
3条回答
  • 2021-01-29 02:20

    Id was mismatching

    Change your layout like this

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context="com.example.luke.sinhalasindu.Ruwan_Hettiaracchi" >
    
        <WebView
            android:id="@+id/webView"
            android:layout_width="400dp"
            android:layout_height="200dp" />
    
    </RelativeLayout>
    

    In java initialize WebView variable like this

    WebView view = (WebView) findViewById(R.id.webView);
    
    0 讨论(0)
  • 2021-01-29 02:29

    From your layout

    WebView view = (WebView) this.findViewById(R.id.webView);
    

    should be

    WebView view = (WebView) this.findViewById(R.id.webView1);
    
    0 讨论(0)
  • 2021-01-29 02:33

    add android:id="@+id/webView" on activity_main.xml

    0 讨论(0)
提交回复
热议问题