我试图为webView显示一个循环的不确定加载指示器,但是尽管在这里阅读了大量的答案,我的构建失败了。我收到错误java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ProgressBar.setVisibility(int)' on a null object reference
。我在fragment.xml文件中设置了进度条,如下所示:
<ProgressBar
android:id="@+id/prgrsbar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:visibility="gone"
android:indeterminateDrawable="@drawable/progress" >
</ProgressBar>
并在其中创建了一个空的progress.xml
文件,其中包含以下内容:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
</selector>
最后,这是我正在使用的片段onCreateView
活动代码:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
//code here
View rootView = inflater.inflate(R.layout.fragment_first, container, false);
String url = "http://winn-brown.co.uk/shmee/";
WebView view = (WebView) rootView.findViewById(R.id.webview);
view.getSettings().setJavaScriptEnabled(true);
view.loadUrl(url);
view.setWebViewClient(new WebViewClient() {
private ProgressBar prgrsBar;
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
prgrsBar.setVisibility(View.VISIBLE);
}
public void onPageFinished(WebView view, String url) {
// do your stuff here
Log.i("message", "website loaded");
}
});
return rootView;
}
在这一行private ProgressBar prgrsBar;
上,它表示“私有字段'prgrsBar'永远不会被分配,尽管在片段的xml文件中有id。如果我在这里遗漏了明显的东西,请道歉。
答案 0 :(得分:0)
添加
$scope.hasAdminRole = function(roles) {
var isAdmin = false;
for(var i = 0; i < roles.length; i++) {
if (roles[i].name == 'Admin') {
isAdmin = true;
break;
}
}
return isAdmin;
}
以下
prgrsBar = (ProgressBar)rootView.findViewById(R.id.prgrsbar);
答案 1 :(得分:0)
您需要在poly = [{"x":0.0, "y":25.0},
{"x":28.5,"y":23.4},
{"x":33.0,"y":21.0},
{"x":39.0,"y":1.5}];
svg.selectAll("polygon")
.data([poly])
.enter().append("polygon")
.attr("points",function(d) {
return d.map(function(d) {
return [scaleX(d.x),scaleY(d.y)].join(",");
}).join(" ");
})
.attr("stroke","white")
.attr("stroke-width",1)
.attr("fill", "none")
.attr("class", "feature")
.on("click", function(d){ alert("HEO"); });
onCreateView