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:
---------------------------------------------------------------------
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
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:
package com.mobilevideoeditor.moved;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
public class EditGalleryView extends Activity {
Uri[] vidUris;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.videogrid);
GridView vGrid=(GridView) findViewById(R.id.vgrid);
vGrid.setAdapter(new VideoAdapter(this));
Uri uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
Log.d("EditGalleryView", "uri:"+uri);
String[] projection = {
MediaStore.Video.Media.DESCRIPTION,
MediaStore.Video.Media.DATA
};
Cursor c = this.managedQuery(uri, projection, null, null,
MediaStore.Video.Media.DATE_ADDED);
Log.d("EditGalleryView", "vids available:" +c.getCount());
ArrayList<Uri> experimentVids = new ArrayList<Uri>();
if (c.getCount() != 0) {
c.moveToFirst();
experimentVids.add(Uri.parse(c.getString(1)));
while (c.moveToNext()) {
experimentVids.add(Uri.parse(c.getString(1)));
}
}
Log.d("ClassName", "experimentVids.length:" +experimentVids.size());
if (experimentVids.size() != 0) {
vidUris = new Uri[experimentVids.size()];
for (int i = 0; i < experimentVids.size(); i++) {
vidUris[i] = experimentVids.get(i);
}
Log.d("EditGalleryView", "vidUris:"+vidUris.length);
}
}
public class VideoAdapter extends BaseAdapter {
private Context mContext;
public VideoAdapter(Context c) {
mContext = c;
}
public int getCount() {
//return mThumbIds.length;
return vidUris.length;
}
public Object getItem(int position) {
//return null;
return position;
}
public long getItemId(int position) {
//return 0;
return position;
}
// 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.setImageURI(vidUris[position]);
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,
};*/
}
}
---------------------------------------------------------------------
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