im just starting out with android studio,
i have imported WebKit but those imports are grayed.
and i cant initialize the webview “private WebView webview” shows errors
how to do it correctly?
JavaScript
x
import android.webkit.WebView
import android.webkit.WebViewClient
import android.webkit.WebChromeClient
import android.webkit.WebSettings
import android.app.Activity
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
class MainActivity : AppCompatActivity() {
private WebView webview
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
}
Advertisement
Answer
I was using kotlin instead of java that was the issue (beginner mistake lol)
my issue was that i couldn’t initialize the webview on my code. but later i figured i was using kotlin as the programming language instead of using java (since syntax is different in java and kotlin) that was the issue. starting a new project with java solved the issue