1
私はアンドロイドアプリで作業しているカスタムカメラとギャラリービューを持っています。私のカメラは、私が正常に私のギャラリーに表示されている特定のフォルダ内の名前として基本的にタイムスタンプ付きの画像を保存します。それは、古いものから最新のもの、またはアルファベット順のこれらの画像をデフォルトで並べ替えるようですが、反対の順序で表示したいのですが...誰かが正しい方向に向けることができますか?出来ますか?これを試してみて、それが動作するかどうか私に教えてギャラリーの日付で画像を並べ替える方法はありますか?
public class GallImageAdapter extends BaseAdapter {
public Cursor cursor;
private int columnIndex;
private Context context;
int imageBackground;
public GallImageAdapter(Context ctx, Cursor cur, int cIn) {
context = ctx;
columnIndex = cIn;
cursor = cur;
}
@Override
public int getCount() {
return cursor.getCount();
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v;
if(convertView ==null){
v = LayoutInflater.from(context).inflate(R.layout.galitem, parent, false);
}else{
v = convertView;
}
ImageView photo = (ImageView) v.findViewById(R.id.imageView);
ImageView border = (ImageView) v.findViewById(R.id.borderView);
ImageView d = (ImageView) v.findViewById(R.id.delView);
// Move cursor to current position
cursor.moveToPosition(position);
// Get the current value for the requested column
int imageID = cursor.getInt(columnIndex);
// obtain the image URI
Uri uri = Uri.withAppendedPath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, Integer.toString(imageID));
String url = uri.toString();
// Set the content of the image based on the image URI
int originalImageId = Integer.parseInt(url.substring(url.lastIndexOf("/") + 1, url.length()));
Bitmap b = MediaStore.Images.Thumbnails.getThumbnail(context.getContentResolver(),
originalImageId, MediaStore.Images.Thumbnails.MINI_KIND, null);
photo.setImageBitmap(b);
photo.setScaleType(ImageView.ScaleType.FIT_CENTER);
return v;
}
}