我有一个Android webview应用程序,显示我的网站, 我想知道是否有办法控制页面的加载状态,并放置一个" Loading ..." webview中每个html页面的脚本, 我也有2个问题,当我启动我的应用程序时,它显示大约4-5秒黑屏 另一个是当我的webview加载时它没有以正确的方式加载网页,但是当我重新加载时,它正常工作。 谢谢你们
这是我的网站"主页"
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Eventi</title>
<link rel="stylesheet" type="text/css" href="CSS/stile.css">
<script src="JS/jquery-1.11.1.js.js"></script>
<script src="JS/func.js"></script>
<?php include ("PHP/phpfiles.php");?>
</head>
<body>
<div id="navigation">
<a href="eventi.php"> <div align="left" style="float:left;margin-left: 5%; margin-top:-1.5%;"><img src="IMG/reload.png" width="30" height="30" alt=""/></div> </a>
<a href="#" style="margin-left:-5.3%;"><img src="IMG/logo_navbar.png" width="300" height="30" alt="Logo" class="logonavig"/></a>
<div align="right" style="float:right;margin-right: 5%;"><img src="IMG/undo.png" width="10" height="11" alt=""/></div>
</div>
<!--
<? if ($_SESSION['FBID']): ?>
<p class="testobparty"><font color="#000000" > Benvenuto/a </font> <font color="#1D49A2" size="5px" style="font-weight:bold;"><? echo $_SESSION['FULLNAME']; ?></font></p>
<? else: ?>
<p class="testobparty"> <a href="LOGIN/1353/fbconfig.php" style="text-decoration:underline; color:#1D49A2; font-weight:bold; font-family:Impact, Haettenschweiler, 'Franklin Gothic Bold', 'Arial Black', sans-serif;"><img src="IMG/buttonfb3.png" height="40" width="300"> </a></p>
<? endif ?> --> <br> <br> <br>
</div>
</div>
<? inserisci_div(); ?>
<div id="footer"> © - 2014 <font color="#FFF">BParty by BParty Staff</font> All rights reserved | <a href="http://www.ask.fm/BPartyOfficial">ASK.FM</a> | <a href="https://www.facebook.com/people/BParty-Profilo/100007646898561">FACEBOOK</a> | <br> Icon made by <a href="http://www.icons8.com" title="Icons8"><font style="font-weight:200">Icons8</font></a> from <a href="http://www.flaticon.com" title="Flaticon"><font style="font-weight:200">www.flaticon.com</font></a> is licensed under <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0"><font style="font-weight:200">CC BY 3.0</font></a>
</div>
</body>
</html>
我认为问题是我的JS文件
$(document).ready( function(){
if ($(window).width() > 1001 && $(window).width() < 10000 )
{
$("#menubar").css("font-size", ((($(window).height()*8)/100)));
$(".fotoevento").css("height", ((($(window).height()*45)/100)));
$(".fotoevento").css("width", ((($(window).height()*100)/100)));
$(".pub").css("margin-left", ((($(window).height()*13)/100)));
$(".testievento").css("font-size", ((($(window).width()*3)/100)));
$("#footer").css("font-size", ((($(window).width()*3)/100)));
//MOBILE
$(".logonavig").css("height", ((($(window).height()*3)/100)));
$(".logonavig").css("width", ((($(window).width()*19)/100)));
}
else if ($(window).width() < 1000)
{
$("#menubar").css("font-size", ((($(window).height()*3)/100)));
$(".fotoevento").css("height", ((($(window).height()*35)/100)));
$(".fotoevento").css("width", ((($(window).width()*90)/100)));
$(".pub").css("margin-left", ((($(window).height()*13)/100)));
$(".testievento").css("font-size", ((($(window).width()*5)/100)));
$(".imamgineeventocompleta").css("margin-top", ((($(window).height()*9)/100)));
$("#footer").css("font-size", ((($(window).width()*2.4)/100)));
//MOBILE
$(".logonavig").css("height", ((($(window).height()*3)/100)));
$(".logonavig").css("width", ((($(window).width()*47)/100)));
}
else {
$("#menubar").css("font-size", ((($(window).height()*3)/100)));
$(".fotoevento").css("height", ((($(window).height()*60)/100)));
$(".fotoevento").css("width", ((($(window).height()*110)/100)));
$(".pub").css("margin-left", ((($(window).height()*60)/100)));
$(".testievento").css("font-size", ((($(window).width()*5)/100)));
//MOBILE
$(".logonavig").css("height", ((($(window).height()*3)/100)));
$(".logonavig").css("width", ((($(window).width()*35)/100)));
}
答案 0 :(得分:-1)
对于您的第一个问题,请将WebViewClient添加到您的webview,并在以下代码中处理文本显示:
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
//getActionBar().setTitle("Loading..."); for example
}
@Override
public void onPageFinished(WebView view, String url) {
//getActionBar().setTitle("Loaded"); for example
}
对于secound问题,请输入setContentView(R.layout.activity_loading);直接在
之后protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_loading);
希望它有所帮助...