关于android:当我点击gridview发布视频活动链接时

when i click gridview post a link to video activity

我有一个视频活动,视频从原始文件夹加载。

我想在我的网格视图中,当我单击一个项目时,它会向视频活动发送视频链接

我可以在GridView中将此地址添加到每个图标中吗?

我的视频名是这样的1.3gp 2.3gp 3.3gp….

Java*

1
2
3
4
5
6
7
8
9
10
11
12
13
14
GridView gridview = (GridView) findViewById(R.id.gridview);
    gridview.setAdapter(new ImageAdapter(this));

    gridview.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {

            // Sending image id to FullScreenActivity
            Intent i = new Intent(getApplicationContext(), video.class);
            // passing array index
            i.putExtra("id", position);
            startActivity(i);
        }

    });

图像适配器.java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
public class ImageAdapter extends BaseAdapter {
private Context mContext;

public ImageAdapter(Context c) {
    mContext = c;
}

public int getCount() {
    return mThumbIds.length;
}

public Object getItem(int position) {
    return null;
}

public long getItemId(int position) {
    return 0;
}

// create a new ImageView for each item referenced by the Adapter
public View getView(int position, View convertView, ViewGroup parent) {
    ImageView imageView;
    if (convertView == null) {  // if it's not recycled, initialize some attributes
        imageView = new ImageView(mContext);
        imageView.setLayoutParams(new GridView.LayoutParams(120, 120));
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        imageView.setPadding(8, 8, 8, 8);
    } else {
        imageView = (ImageView) convertView;
    }

    imageView.setImageResource(mThumbIds[position]);
    return imageView;
}

// references to our images
public Integer[] mThumbIds = {
        R.drawable.sample_2, R.drawable.sample_2,
        R.drawable.sample_2, R.drawable.sample_2,
        R.drawable.sample_2, R.drawable.sample_2,
        R.drawable.sample_2, R.drawable.sample_2,
        R.drawable.sample_2, R.drawable.sample_2,
        R.drawable.sample_2, R.drawable.sample_2,
        R.drawable.sample_2, R.drawable.sample_2,
        R.drawable.sample_2, R.drawable.sample_2,
        R.drawable.sample_2, R.drawable.sample_2,
        R.drawable.sample_2, R.drawable.sample_2,
        R.drawable.sample_2, R.drawable.sample_2,
        R.drawable.sample_2, R.drawable.sample_2
};

}

和视频

1
2
3
4
5
6
7
8
9
add = getIntent().getStringExtra("id");
    VideoView myvid = (VideoView) findViewById(R.id.videoview);

    myvid.setVideoURI(Uri.parse("android.resource://" + getPackageName() +"/"+R.raw.sigarintro));
    myvid.setMediaController(new MediaController(this));
    myvid.requestFocus();


    myvid.start();


不确定问题出在哪里,但如果我理解正确:我的活动包含两个片段,如果我想从我的活动中获得一些变量/值到片段,我只需键入片段:

1
String currentPath = ((MainActivity)getActivity()).currentPath;

我想这条线可能是类似的…链接


1
2
3
4
5
6
7
path ="your path";

mVideoView.setVideoPath(path);
myvid.setMediaController(new MediaController(this));
myvid.requestFocus();

myvid.start();