J'ai une application qui récupère du texte à partir d'une page Web et l'affiche à l'écran. Je voudrais mettre après le texte une vidéo du web. Comment pourrais-je faire ça? Si j'aime bien le code suivant, l'application plante (exception du pointeur nul).Intégration vidéo Android
Mon code:
LinearLayout tt= (LinearLayout)findViewById(R.id.kiu);
WebView webview;
tt.addView(fin); // fin is the TextView
webview.getSettings().setJavaScriptEnabled(true);
webview.loadUrl("http://www.youtube.com/embed/j4Wmjl7jxQo");
tt.addView(webview);
main.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:scrollbars="vertical"
android:background="#FFFFFF"
>
<LinearLayout
android:id="@+id/kiu"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="0dp">
</LinearLayout>
</ScrollView>
Je ne peux pas comprendre ce que dois-je faire .. Je voudrais que mon application pour afficher this au lieu de this.
Si je fais le webview dans le xml, quand j'entre dans l'activité contenant le texte, je suis automatiquement dirigé vers youtube. Je voudrais avoir la vidéo intégrée là et quand je clique dessus, pour être redirigé vers la page. Pourrais-tu me dire comment je peux faire ça? – Teo
Vous voudrez alors la première option. Débarrassez-vous du webview dans votre xml, et débarrassez-vous de l'appel de findViewById() et employez juste webview = new WebView (ceci); et mettez tt.addView (webview); après avoir appelé loadUrl() – FoamyGuy