Я учу Android и хочу сделать WebView во Фрагменте.Я написал это
package app.com.youtubeapiv3.fragments;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import app.com.youtubeapiv3.R;
/**
* A simple {@link Fragment} subclass.
*/
public class WebView extends Fragment {
public WebView() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_web_view, container, false);
WebView mWebView = (WebView) v.findViewById(R.id.webview);
mWebView.loadUrl("https://google.com");
// Enable Javascript
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
return v;
}
}
Я получаю сообщение об ошибке типа
ошибка: недопустимое объявление метода;возвращаемый тип обязательная ошибка: ожидается
Метод loeadUrl () и getSettings ();не может быть решен.Я не знаю, что мне делать.
![enter image description here](https://i.stack.imgur.com/Rw6oz.png)
XML
<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context=".fragments.WebView">
<!-- TODO: Update blank fragment layout -->
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/hello_blank_fragment" />
</RelativeLayout>