我想获得一个进度条,显示直到网页加载。如果用户没有网络连接而不是文本或吐司显示...但我无法得到它的工作..搜索整个网站。我认为它很容易添加进度条类,消费活动...... 这里是我的课堂和布局进度条和webview中没有互联网连接片段
package com.nirav.rpta.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 android.webkit.WebView;
import com.nirav.rpta.R;
public class OneFragment extends Fragment{
public OneFragment() {
// Required empty public constructor
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.fragment_one, container, false);
WebView heroespage = (WebView) rootView.findViewById(R.id.webview);
WebSettings webSettings = heroespage.getSettings();
webSettings.setJavaScriptEnabled(true);
heroespage.loadUrl("http://google.co.in/");
return rootView;
}}
和我的布局
<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="com.nirav.rpta.fragments.OneFragment">
<WebView
android:id="@+id/webview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
/></RelativeLayout>
工作谢谢.....进度条现在可见...但没有错误信息,当没有互联网连接..解决这也请 –
你添加代码,我写道:“/ /显示错误敬酒“? – marmor