2014-12-29 4 views
-1

У меня есть приложение для Android, которое показывает мой сайт, Я хочу знать, есть ли способ контролировать состояние загрузки страницы и поставить «Загрузка .. . »для каждой страницы html в webview, , и у меня также есть 2 проблемы, когда я запускаю свое приложение, он показывает около 4-5 секунд черный экран , а другой - тот, что когда мой веб-просмотр загружен, он не делает Неправильно загружайте веб-страницу, но когда я перезагружаюсь, она работает правильно. Спасибо ребятаКак загрузить страницу в Webview android

Это мой сайт «Домашняя страница»

<!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 &nbsp; </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))); 
     } 

ответ

-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 
} 

Для th проблемы, поставьте setContentView (R.layout.activity_loading); непосредственно после

protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_loading); 

Надеется, что это помогает ...

Смежные вопросы