【发布时间】:2011-12-02 05:36:40
【问题描述】:
我有一个从网页中获取一些文本并将其显示在屏幕上的应用程序。我想在文本之后放一段来自网络的视频。我怎么能那样做?如果我喜欢下面的代码,应用程序就会崩溃(空指针异常)。
我的代码:
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>
【问题讨论】:
标签: android video request embed