我有一个列表视图,我希望当该行点击它播放视频时,我的代码是:
public void onItemClick(AdapterView<?> a, View v, int position, long id)
{
setContentView(R.layout.video);
VideoView videoview = (VideoView)findViewById(R.id.videoview);
MediaController mc = new MediaController(?);
videoview.setMediaController(mc);
videoview.setVideoURI(Uri.parse((String) myList.getItemAtPosition(position)));
videoview.requestFocus();
videoview.start();
}
答案 0 :(得分:0)
请在此putExtra
Activity
方法
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
Object o = this.getListAdapter().getItem(position);
String videouri= o.toString();
Intent in = new Intent(getApplicationContext(), VideoExamplesActivity.class);
in.putExtra(KEY_NAME, videouri);
startActivity(in);
Toast.makeText(this, "You have chosen the videouri: " + " " + videouri, Toast.LENGTH_LONG).show();
}