CODE ISSUE - Video Array cannot be resolved


Last Updated:

  1. kivy

    kivy Member This Topic's Starter

    Joined:
    Jul 13, 2010
    Messages:
    17
    Likes Received:
    0
    Hi again

    after having solved the issues that caused the problem I described below, I ran into an even worse problem... I am just trying to load the videos from the sd card into my GridView, but now when I compiled it the entire app disappeared from the emulator... I have no idea what's causing the problem, I really really could use some help.

    Thank you in advance...

    Here is the code I was working on before the app disappeared:

    Code (Text):
    1. package com.mobilevideoeditor.moved;
    2.  
    3. import java.util.ArrayList;
    4.  
    5. import android.app.Activity;
    6. import android.content.Context;
    7. import android.database.Cursor;
    8. import android.net.Uri;
    9. import android.os.Bundle;
    10. import android.provider.MediaStore;
    11. import android.util.Log;
    12. import android.view.View;
    13. import android.view.ViewGroup;
    14. import android.widget.BaseAdapter;
    15. import android.widget.GridView;
    16. import android.widget.ImageView;
    17.  
    18.  
    19.  
    20.  
    21. public class EditGalleryView extends Activity {
    22.     Uri[] vidUris;
    23.     public void onCreate(Bundle savedInstanceState) {
    24.         super.onCreate(savedInstanceState);
    25.         setContentView(R.layout.videogrid);
    26.        
    27.         GridView vGrid=(GridView) findViewById(R.id.vgrid);
    28.         vGrid.setAdapter(new VideoAdapter(this));
    29.        
    30.         Uri uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
    31.        
    32.         Log.d("EditGalleryView", "uri:"+uri);
    33.         String[] projection = {
    34.                 MediaStore.Video.Media.DESCRIPTION,
    35.                 MediaStore.Video.Media.DATA  
    36.     };
    37.      
    38.         Cursor c = this.managedQuery(uri, projection, null, null,
    39.                 MediaStore.Video.Media.DATE_ADDED);
    40.                          Log.d("EditGalleryView", "vids available:" +c.getCount());
    41.  
    42.                          ArrayList<Uri> experimentVids = new ArrayList<Uri>();
    43.  
    44.                        
    45.                              if (c.getCount() != 0) {
    46.                                  c.moveToFirst();
    47.                                   experimentVids.add(Uri.parse(c.getString(1)));
    48.                                  while (c.moveToNext()) {
    49.                                          experimentVids.add(Uri.parse(c.getString(1)));
    50.                                                              
    51.                                   }
    52.                       }
    53.                              Log.d("ClassName", "experimentVids.length:" +experimentVids.size());
    54.                                                   if (experimentVids.size() != 0) {
    55.                                                     vidUris = new Uri[experimentVids.size()];
    56.                                                       for (int i = 0; i < experimentVids.size(); i++) {
    57.                                                           vidUris[i] = experimentVids.get(i);
    58.                                                       }
    59.                                                       Log.d("EditGalleryView", "vidUris:"+vidUris.length);
    60.                                                   }
    61.                                               }
    62.    
    63.    
    64.     public class VideoAdapter extends BaseAdapter {
    65.         private Context mContext;
    66.        
    67.         public VideoAdapter(Context c) {
    68.             mContext = c;
    69.         }
    70.  
    71.         public int getCount() {
    72.             //return mThumbIds.length;
    73.             return vidUris.length;
    74.         }
    75.  
    76.         public Object getItem(int position) {
    77.             //return null;
    78.             return position;
    79.         }
    80.  
    81.         public long getItemId(int position) {
    82.             //return 0;
    83.             return position;
    84.         }
    85.  
    86.         // create a new ImageView for each item referenced by the Adapter
    87.         public View getView(int position, View convertView, ViewGroup parent) {
    88.            ImageView imageView;
    89.             if (convertView == null) {  // if it's not recycled, initialize some attributes
    90.                 imageView = new ImageView(mContext);
    91.                 imageView.setImageURI(vidUris[position]);
    92.                 imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
    93.                 imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    94.                 imageView.setPadding(8, 8, 8, 8);
    95.             } else {
    96.                 imageView = (ImageView) convertView;
    97.             }
    98.  
    99.           //  imageView.setImageResource(mThumbIds[position]);
    100.             return imageView;
    101.         }
    102.  
    103.        /* // references to our images
    104.         private Integer[] mThumbIds = {
    105.                 R.drawable.sample_2, R.drawable.sample_3,
    106.                 R.drawable.sample_4, R.drawable.sample_2,
    107.                 R.drawable.sample_6, R.drawable.sample_3,
    108.                 R.drawable.sample_4, R.drawable.sample_1,
    109.                
    110.         };*/
    111.        
    112.     }  
    113.  
    114. }
    115.  
    116.  


    ---------------------------------------------------------------------
    Hi there,

    I am trying to retrieve videos from the phone's SD card, but I just ran into a problem because when the array that I use for the videos is called I get cannot be resolved errors... I thought I declared it properly, but apparently not... If someone could help me find the error in my code and tell me what I did wrong, that would be great. Thanks in advance...

    Cheers
     

    Advertisement

Share This Page

Loading...