Hi there,
I was working on the code below, trying to load all available videos
from the emulator sdcard into my gridview, I compiled and wanted to
test it, but the app has disappeared entirely from my emulator... what
can I do or better what have I done wrong in the code that could cause
a problem like that...???
I could really need some help, so if anyone may see what I have done
wrong, please tell, because I have no idea what's wrong...Thanks in
advance...
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,
};*/
}
}
--
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en