Comment configurer WebView dans Android?WebView dans android
3
A
Répondre
12
En savoir plus: WebView on Android developers
0
**main.xml (res/layout)**
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="@+id/urlEdit"
android:layout_width="300dip"
android:layout_height="wrap_content"
android:inputType="textWebEditText"
android:imeOptions="actionDone" />
<Button
android:id="@+id/goButton"
android:layout_width="50dip"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_toRightOf="@id/urlEdit"
android:background="@drawable/redbutton"
android:text="Go..."
android:textColor="#fcfcfc" />
</RelativeLayout>
<WebView
android:id="@+id/webView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
WebView Activtiy
public class WebViewExampleActivity extends Activity {
public WebView webView;
public Button goButton;
public EditText urlEdit;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webView = (WebView)findViewById(R.id.webView);
goButton = (Button)findViewById(R.id.goButton);
urlEdit = (EditText)findViewById(R.id.urlEdit);
webView.setWebViewClient(new DemoWebViewClient());
goButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
openUrl();
}
});
}
public void openUrl() {
String url;
url = urlEdit.getText().toString();
webView.loadUrl(url);
}
public class DemoWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
}
0
ils sont ici
xml
<WebView
android:id="@+id/web_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1.0" />
classe
WebView webview = (WebView) findViewById(R.id.web_view);
webview.getSettings().setSupportZoom(true);
webview.getSettings().setBuiltInZoomControls(true);
webview.loadUrl("file:///android_asset/yourHtmlFile.html");
Questions connexes
- 1. GeoLocation dans Android Webview
- 2. JavaScript Android dans WebView
- 3. Sockets dans WebView Android
- 4. webview dans android
- 5. webview dans android
- 6. Copie Android WebView à Webview
- 7. Android: webview
- 8. webView android
- 9. Android WebView
- 10. android WebView
- 11. Android WebView
- 12. Android WebView
- 13. Android - image locale dans WebView
- 14. Webview Android dans Unity3d (C#)
- 15. javascript dans android webview Problème?
- 16. Problèmes avec WebView dans Android
- 17. Http Referer dans WebView - Android
- 18. Injecter javascript dans android WebView
- 19. pages Web android dans webview
- 20. Contrôle de Webview dans android
- 21. Obtenir java.lang.NullPointerException Dans Android WebView
- 22. Connexion Facebook dans android WebView
- 23. Webview Android dans un service?
- 24. Bouton Android +1 dans WebView
- 25. Android chinois charcuteries dans WebView
- 26. URL GoogleMap dans WebView Android
- 27. Sencha camembert dans Android Webview
- 28. géolocalisation dans webview pour android
- 29. Page Flash Android dans WebView
- 30. Webview Problème dans l'émulateur Android
Vérifiez mon tutoriel. http://www.taiic.com/2011/03/12/webview-template-for-android-sdk/ Je fournis également la source pour cela. – GeneK