views:

95

answers:

2

i am beginner in Android app development i am working on a app which lists the videos and images and uploads them from android phone to the windows server,

Button Listvideo = (Button) findViewById(R.id.Listvideo); Listvideo.setOnClickListener(this);

help me out with the listing images and videos........................

A: 

within your OnClick method:

Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, 1);

onActivityResult method:

protected void onActivityResult(int requestCode, int resultCode,
        Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);

    if (resultCode == RESULT_OK) {
        Uri photoUri = intent.getData();

        if (photoUri != null) {
            try {
                Bitmap bitmap = MediaStore.Images.Media.getBitmap(this
                    .getContentResolver(), photoUri);
                your_imgv.setImageBitmap(bitmap);
                profilePicPath = photoUri.toString();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
Praveen Chandrasekaran
+1  A: 

Here you can find a tutorial explaining how to load images:

http://mihaifonoage.blogspot.com/2009/09/displaying-images-from-sd-card-in.html

In part 2, the tutorial explains how the images loading in the background so that it goes faster:

http://mihaifonoage.blogspot.com/2009/09/displaying-images-from-sd-card-in.html

To display video files you should change the cursor so that it no points to images, but to videos

Roflcoptr