Я пытаюсь открыть url под webview. У меня есть код ниже:webview не отображается корректно
public class FragmentWebView extends Fragment {
TextView webview_bar_title;
ImageButton menu;
WebView wv;
public FragmentWebView() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_webview, container,
false);
menu = (ImageButton) view.findViewById(R.id.webview_menu);
menu.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
((MainActivity) getActivity()).onBackPressed();
}
});
webview_bar_title = (TextView) view.findViewById(R.id.webview_share);
webview_bar_title.setText("Share");
wv = (WebView) view.findViewById(R.id.fragment_webview);
wv.getSettings().setJavaScriptEnabled(true);
wv.loadUrl("http://www.google.com");
return view;
}
}
А вот мой XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/webview_actionbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageButton
android:id="@+id/webview_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/arrow_left" />
<TextView
android:id="@+id/webview_share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp" />
</RelativeLayout>
<WebView
android:id="@+id/fragment_webview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/webview_actionbar" />
</RelativeLayout>
Я пытаюсь загрузить Google страницу в моей WebView. Но он не работает и дал мне ошибки, такие как веб-сайт недоступен. Веб-страница google может быть временно недоступна или она может постоянно переходить на новый адрес. И предложение? Заранее спасибо.
Вы подключаетесь к Интернету? –
есть, я. Это проблема эмулятора? – Shumin
попробуйте заняться серфингом в Интернете, используя веб-сайт по умолчанию в эмуляторе и см. Раздел –