在我的應用程序中,我是使用JSON將數據提取到ListView中,並且每當用戶在其他活動中點擊任何顯示該特定內容的列表項時。如何顯示視頻代替視頻URL
JSON包含4 JSON對象,即: - 編號,名稱,描述,URL
其中網址是在線mp4視頻網址
像我傳遞名稱,描述以同樣的方式我以字符串格式傳遞視頻網址,但在這裏我需要一個小小的改變,如何顯示視頻的活動到位o f URL?
我在Android的新的,但我認爲,只有必要的代碼是確定告訴你如何我這麼在這裏我們去做完整的源代碼,而不是
,
public class SingleContactActivity extends Activity {
// json video url object
private static final String TAG_URL = "url";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_single_contact);
// getting intent data
Intent in = getIntent();
String mobile = in.getStringExtra(TAG_URL);
TextView lblMobile = (TextView) findViewById(R.id.mobile_label);
lblMobile.setText(mobile);
}
}
activity_single_contact。 XML: -
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp">
<!-- Mobile Label -->
<!-- in place of TextView want to show Video -->
<TextView android:id="@+id/mobile_label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textStyle="bold"/>
</LinearLayout>
編輯:給我新學習夥伴
Uri uri=Uri.parse(mobile);
VideoView video=(VideoView)findViewById(R.id.videoView1);
video.setVideoURI(uri);
video.start();
..................................... .....
<VideoView
android:id="@+id/videoView1"
android:layout_width="wrap_content"
android:layout_height="180dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" />
用的ImageView,並設置視頻Thumbnil更換的TextView到ImageView的。這對你很有用 – 2014-02-28 05:53:28