我想在WebView中添加进度条,但是当我尝试按照这个和这个的方法添加进度条时,它们非常混乱,我无法理解,因为我是新手。
我想在我的Tab2活动中添加一个进度条。
package com.freerechargeapp.weebly.free_recharge_app;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
public class tab2 extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.tab2, container, false);
WebView webView = (WebView) view.findViewById(R.id.webview1);
webView.loadUrl("http://google.com");
return view;
}
这是我的tab2.xml文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webview1"
android:layout_height="match_parent"
android:layout_width="match_parent"
/>
<ProgressBar
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:id="@+id/progressBar1"/>
</RelativeLayout>
</LinearLayout>
tab2
xml。 - IntelliJ Amiya