我有这个在我的第一个活动:在android中正确传递数据?
private AdapterView.OnItemClickListener _itemClickLis = new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View v, int position, long id)
{
// Now we want to actually get the data location of the file
String [] proj={MEDIA_DATA};
// We request our cursor again
_cursor = managedQuery(_contentUri,
proj, // Which columns to return
null, // WHERE clause; which rows to return (all rows)
null, // WHERE clause selection arguments (none)
null); // Order-by clause (ascending by name)
// We want to get the column index for the data uri
int count = _cursor.getCount();
//
_cursor.moveToFirst();
//
_columnIndex = _cursor.getColumnIndex(MEDIA_DATA);
// Lets move to the selected item in the cursor
_cursor.moveToPosition(position);
// And here we get the filename
String filename = _cursor.getString(_columnIndex);
//*********** You can do anything when you know the file path :-)
showToast(filename);
Intent i = new Intent("com.ave.EDITORSCREEN");
i.putExtra("mnt/sdcard-ext", _ID);
startActivity(i);
}
这不是完整的代码,但作为完整的代码从SD卡收集所有的视频缩略图,并显示他们沿着它们路径的(在祝酒词)。我希望能够点击缩略图,并传递到下一个活动的数据进行播放,停止,暂停,等你能看到我在第一个活动传递的数据:
public class Editor extends Activity {
ImageButton video1;
int isClicked = 0;
ImageButton audio;
int isClicked1 = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.editor);
video1 = (ImageButton) findViewById(R.id.video1);
video1.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (isClicked == 0) {
video1.setImageResource(R.drawable.video_pressed);
isClicked = 1;
} else {
video1.setImageResource(R.drawable.video1);
isClicked = 0;
}
}
});
audio = (ImageButton) findViewById(R.id.audio);
audio.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (isClicked1 == 0) {
audio.setImageResource(R.drawable.audio_pressed);
isClicked1 = 1;
} else {
audio.setImageResource(R.drawable.audio);
isClicked1 = 0;
}
}
});
}
}
我想要得到的数据,我将需要把
String data = getIntent().getStringExtra("mnt/sdcard-ext");
但在哪里的onCreate方法?或者,这是甚至正确的方式来获得传递的数据?最后,我怎样才能播放视频?是否有某种说视频播放器的代码?如果是的话,我会把它放在我最后的活动中?