Football Fans: Download the 2012 Schedule App from Google Play!


Go Back   Android Forums > Android Development > Application Development

Application Development Dev Lounge for the Coder Folks



Reply
 
LinkBack Thread Tools
Old July 14th, 2010, 08:37 PM   #1 (permalink)
Junior Member
 
Join Date: Jul 2010
Posts: 17
 
Device(s):
Thanks: 1
Thanked 0 Times in 0 Posts
Surprised Grid View with Videos

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,
	            
	    };
    	
    }
    
  
}

kivy is offline  
Last edited by kivy; July 15th, 2010 at 06:29 AM. Reason: added code
Reply With Quote
Sponsors
Old July 21st, 2010, 09:39 PM   #2 (permalink)
Junior Member
 
Join Date: Mar 2010
Location: dayton, oh
Posts: 27
 
Device(s): Motorola Droid, Archos 5 IT, Motorola Atrix, 46" Sony Google TV, Nexus S, Galaxy Nexus
Thanks: 2
Thanked 1 Time in 1 Post
Default

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.
jungajuice is offline  
Reply With Quote
Reply

Bookmarks

Tags
gridview, video access


Go Back   Android Forums > Android Development > Application Development User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find View by position in a grid nopris Developer 101 1 December 12th, 2010 03:05 PM
Problem with Grid View TheCompBoy Application Development 1 November 4th, 2010 09:49 AM
How to populate a grid view from sqlite KittyA Introductions 4 August 24th, 2010 07:35 AM
Grid View and Text File Beanstalk Developer 101 6 July 26th, 2010 08:00 AM
Grid view questions 343GS Application Development 0 June 20th, 2010 09:38 PM



All times are GMT -5. The time now is 11:30 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo