I use gridView
to get the file list. But it can not use filelist.get(position)
I want to get the Thumbnails
by using
MediaStore.Images.Thumbnails.getThumbnail(getActivity().getContentResolver(), origId, Images.Thumbnails.MICRO_KIND, null);
But what the origId
of image here ???
Is that mean path
or name
?
-------------------------------------------------EDIT---------------------------------------
The full code is like the following:
I want to get Thumbnails at getView
.
viewTag
is the other class , it store the textview
.
so viewTag.mFilename.setText(filename);
is equal to Textview.setText
.
public class LocalFileListAdapter extends BaseAdapter {
private LayoutInflater mInflater ;
private ArrayList<FileNode> mFileList ;
private static final String TAG = "MJPEG Player" ;
private Context mContext;
public LocalFileListAdapter(LayoutInflater inflater, ArrayList<FileNode> fileList) {
mInflater = inflater ;
mFileList = fileList ;
}
public void GridAdapter(Context ctx) {
// TODO Auto-generated method stub
mContext = ctx;
}
@Override
public int getCount() {
return mFileList == null ? 0 : mFileList.size() ;
}
@Override
public Object getItem(int position) {
return mFileList == null ? null : mFileList.get(position) ;
}
@Override
public long getItemId(int position) {
return position ;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewTag viewTag ;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.filelist_row, null) ;
TextView fileListName = (TextView) convertView.findViewById(R.id.fileListName);
fileListName.setSelected(true);
viewTag = new ViewTag(mContext , (ImageView) convertView.findViewById(R.id.fileListThumbnail),
(ImageView) convertView.findViewById(R.id.select) ,
mFileList.get(position) , fileListName ,
(TextView) convertView.findViewById(R.id.fileListSize) ,
(ImageView) convertView.findViewById(R.id.video_layout) ,
(TextView) convertView.findViewById(R.id.fileListTime));
convertView.setTag(viewTag) ;
} else {
viewTag = (ViewTag) convertView.getTag() ;
}
viewTag.mFileNode = mFileList.get(position) ;
String filename = viewTag.mFileNode.mName.substring(viewTag.mFileNode.mName.lastIndexOf("/") + 1) ;
viewTag.mFilename.setText(filename);
MediaStore.Images.Thumbnails.getThumbnail(getActivity().getContentResolver(), Long.parseLong(mFileList.get(position)), Images.Thumbnails.MICRO_KIND, null);
return convertView ;
}
}
How to get the image Id ?
That's just an ID that each image has.
From the docs:
The original image for the thumbnail Type: INTEGER (ID from Images table)
http://developer.android.com/reference/android/provider/MediaStore.Images.Thumbnails.html#IMAGE_ID
So, it's neither the path, or the name. It's an internally generated ID for each image in the MediaStore. It's generally the Uri to the image.