Amigo coloquei esse codigo no meu MainActivity.java e p codigo fica com marcação vermelha de erro.Segue abaixo o codigo do meu MainActivity.javapackage br.exemplowebview;
import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.FrameLayout;
import android.widget.ProgressBar;
import android.graphics.Bitmap;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final ProgressBar pb = new ProgressBar(this);
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.CENTER;
pb.setLayoutParams(lp);
final FrameLayout fl = (FrameLayout) findViewById(R.id.frameLayout);
final WebView wv = (WebView) findViewById(R.id.webView);
wv.loadUrl("http://www.meusite.com.br");
wv.setWebViewClient(new WebViewClient(){
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon){
/*ProgressBar pb = (ProgressBar) findViewById(R.id.progress);
pb.setVisibility(View.VISIBLE);*/
fl.addView(pb);
}
@Override
public void onPageFinished(WebView view, String url){
//ProgressBar pb = (ProgressBar) findViewById(R.id.progress);
//pb.setVisibility(View.INVISIBLE);
fl.removeView(pb);
wv.setVisibility(View.VISIBLE);
}
});
}
}
Em terça-feira, 28 de julho de 2015 19:51:28 UTC-3, wesley lima da silva escreveu:Faz assim, tenta identificar essa parte e inseri esse código,não consegui mostrar melhor tô usando celular, espero que lhe ajude.
... Seu codigo
WebView wv = (WebView) findViewById(R.id.webview);WebSettings webSettings = wv.getSettings();
webSettings.setJavaScriptEnabled(true);
wv.loadUrl("http://www.meusite.com.br");wv.setWebViewClient(new WebViewClient(){
Continua seu código ...
Em 28/07/2015 19:40, "Pedro horlando" <xva...@gmail.com> escreveu:Obrigado pela sua resposta amigo mas como sou iniciante to boiando nesse texto que eu já ate tinha visto mas não sei onde colocar esses códigos.--
Em terça-feira, 28 de julho de 2015 19:16:19 UTC-3, Marcelo H escreveu:Por padrão javascript é desabilitado na webview.
http://developer.android.com/guide/webapps/webview.htmlEnabling JavaScript
JavaScript is disabled in a
WebViewby default. You can enable it through theWebSettingsattached to yourWebView. You can retrieveWebSettingswithgetSettings(), then enable JavaScript withsetJavaScriptEnabled().For example:
WebView myWebView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
WebSettingsprovides access to a variety of other settings that you might find useful. For example, if you're developing a web application that's designed specifically for theWebViewin your Android application, then you can define a custom user agent string withsetUserAgentString(), then query the custom user agent in your web page to verify that the client requesting your web page is actually your Android application.Em 28 de julho de 2015 18:57, Pedro horlando <xva...@gmail.com> escreveu:--Olá amigos tudo bem!Bom gostaria da ajuda de você para resolver um problema com um webview que estou fazendo onde o site tem vários videos e de play de diferentes site, porem o sempre pede para ativar javascript como mostra na foto abaixo ate a parte do flash já resolve mas esse javascript ta osso.
Meu arquivo MainActivity esta assim:
import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.FrameLayout;
import android.widget.ProgressBar;
import android.graphics.Bitmap;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final ProgressBar pb = new ProgressBar(this);
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.CENTER;
pb.setLayoutParams(lp);
final FrameLayout fl = (FrameLayout) findViewById(R.id.frameLayout);
final WebView wv = (WebView) findViewById(R.id.webView);
wv.loadUrl("http://www.meusite.com.br");
wv.setWebViewClient(new WebViewClient(){
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon){
/*ProgressBar pb = (ProgressBar) findViewById(R.id.progress);
pb.setVisibility(View.VISIBLE);*/
fl.addView(pb);
}
@Override
public void onPageFinished(WebView view, String url){
//ProgressBar pb = (ProgressBar) findViewById(R.id.progress);
//pb.setVisibility(View.INVISIBLE);
fl.removeView(pb);
wv.setVisibility(View.VISIBLE);
}
});
}
}
Obrigado a todos
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--- Marcelo Henrique -"Se não puder se destacar pelo talento, vença pelo esforço." (Dave Weinbaum)."Mate o pecado antes que ele o mate." ( Richard Baxter ).
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.






0 comentários:
Postar um comentário