• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Grid View with Videos

kivy

Newbie
Hi there,

I got a question because I am at the moment stuck. I put some videos on my emulator SD card and would like to access them via the GridView and when you click on a video, a menu should open. How could I do that? Would be great if someone could help me out here...

Thanks.

---------
What I mean is: based on this code from the Grid View Tut, what would I need to change to display videos from the SD card:

Code:
public class EditGalleryView extends Activity {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.videogrid);
        
        GridView vGrid=(GridView) findViewById(R.id.vgrid);
        vGrid.setAdapter(new VideoAdapter(this));
    }
    
    public class VideoAdapter extends BaseAdapter {
    	private Context mContext;
    	
		public VideoAdapter(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(85, 85));
	            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
	    private Integer[] mThumbIds = {
	            R.drawable.sample_2, R.drawable.sample_3,
	            R.drawable.sample_4, R.drawable.sample_2,
	            R.drawable.sample_6, R.drawable.sample_3,
	            R.drawable.sample_4, R.drawable.sample_1,
	            
	    };
    	
    }
    
  
}
 
you can pass VideoView instead of ImageView back through getView(). You will have to set up each VideoView within the method to find and associate the video with it from your sd instead of pulling a drawable resource.
 
Back
Top Bottom