Je veux savoir comment désactiver et activer le bouton de menu avant comme navigateur privé d'android.Je suis en train d'écrire une application où j'affiche 3 webviews et je veux intégrer les fonctionnalités de base des propres options de navigateur d'android. Tout fonctionne correctement à partir de maintenant. La seule chose est 'forward'menu item est toujours activé.J'ai mentionné conditoin aussi pour si canGoFwd puis goFwd. La chose est, je l'ai défini les éléments de menu séparément et écrit avant la fonction séparément, problème est en train de changer de façon dynamique les états pour le bouton « avant »android webview bouton avant
3
A
Répondre
4
private WebView webView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
webView = (WebView) findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
final Button previousButton =(Button) findViewById(R.id.previousButton);
previousButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(webView.canGoBack()){
webView.goBack();
}
}
});
final Button forwardButton =(Button) findViewById(R.id.forwardButton);
forwardButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(webView.canGoForward()){
webView.goForward();
}
}
});
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
// TODO Auto-generated method stub
super.onPageStarted(view, url, favicon);
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(webView, url);
previousButton.setEnabled(view.canGoBack());
forwardButton.setEnabled(view.canGoForward());
}
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
super.onReceivedError(webView, errorCode, description, failingUrl);
Toast.makeText(WebViewActivity.this, description, Toast.LENGTH_LONG);
}
});
webView.loadUrl("");
fichier webview.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<WebView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<Button
android:id="@+id/previousButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:enabled="false"
android:text="previous"/>
<Button
android:id="@+id/forwardButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/previousButton"
android:text="forward"
android:enabled="false" />
</RelativeLayout>
Questions connexes
- 1. Bouton Android +1 dans WebView
- 2. Bouton pour un webview android
- 3. Pinch Zoom avant dans le Webview [Android]
- 4. Retour Bouton Problème dans Android Webview
- 5. Bouton Précédent dans un WebView Android?
- 6. Garder un bouton sous WebView dans Android
- 7. android 4 hilight bouton sélectionné dans WebView
- 8. Android bouton fb comme dans WebView
- 9. indicateur d'activité avant webView
- 10. Android WebView
- 11. Android: webview
- 12. Comment ajouter un bouton à un Webview sur Android?
- 13. Webview Android clignote avant de changer de page
- 14. Copie Android WebView à Webview
- 15. Webview temporaire Android
- 16. Aide avec webview - android
- 17. données de charge Webview avant onClick
- 18. Android: Webview et Activité
- 19. Android webview limited loading
- 20. Obtenir Html de WebView avant de rendre
- 21. webView android
- 22. android WebView
- 23. Android WebView
- 24. Android WebView
- 25. android webview cliquez simulation
- 26. Webview Android inactif déroulant
- 27. Android Webview avec bouton de retour, si autre
- 28. Android: bouton sur un élément WebView (.png-Image)
- 29. Cliquez sur le bouton dans Android WebView programme
- 30. Android et Facebook bouton "like" en utilisant webview - connexion requise