播放视频时出现问题:(

时间:2011-03-08 06:27:49

标签: android android-listview

我有一个列表视图,我希望当该行点击它播放视频时,我的代码是:

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();
}

1 个答案:

答案 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();
}