Problem in playing video :(
I have a list view and I want when the row get click it play video, my code is :
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);
开发者_JS百科 videoview.setVideoURI(Uri.parse((String) myList.getItemAtPosition(position)));
videoview.requestFocus();
videoview.start();
}
Please use putExtra
method in this 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();
}
精彩评论