public class ImageAdapter extends BaseAdapter { private Context context; public ImageAdapter(Context c) { // TODO Auto-generated method stub context = c; } public int getCount() { // TODO Auto-generated method stub return ImageList.size(); } public Object getItem(int position) { // TODO Auto-generated method stub return position; } public long getItemId(int position) { // TODO Auto-generated method stub return position; } public View getView(final int position, View convertView, ViewGroup parent) { // TODO Auto-generated method stub LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); if (convertView == null) { convertView = inflater.inflate(R.layout.list_upload, null); } // ColImgName TextView txtName = (TextView) convertView.findViewById(R.id.ColImgName); strPath = ImageList.get(position).toString(); // Get File Name fileName = strPath.substring( strPath.lastIndexOf('/')+1, strPath.length() ); File file = new File(strPath); @SuppressWarnings("unused") long length = file.length(); txtName.setText(fileName); // Image Resource ImageView imageView = (ImageView) convertView.findViewById(R.id.ColImgPath); Bitmap bm = BitmapFactory.decodeFile(strPath); imageView.setImageBitmap(bm); // ColStatus final ImageView txtStatus = (ImageView) convertView.findViewById(R.id.ColStatus); txtStatus.setImageResource(R.drawable.bullet_button); // progressBar final ProgressBar progress = (ProgressBar) convertView.findViewById(R.id.progressBar); progress.setVisibility(View.GONE); //btnUpload final ImageButton btnUpload = (ImageButton) convertView.findViewById(R.id.btnUpload); btnUpload.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Upload btnUpload.setEnabled(false); startUpload(position); } }); // Data final ImageButton btnData = (ImageButton) convertView.findViewById(R.id.btnData); btnData.setOnClickListener(new View.OnClickListener() { @SuppressWarnings("deprecation") public void onClick(View v) { // Print fileName=ImageList.get(position).toString().substring(strPath.lastIndexOf('/')+1, strPath.length()); showDialog(DIALOG_LOGIN); } }); // Print final ImageButton btnPrint = (ImageButton) convertView.findViewById(R.id.btnPrint); btnPrint.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { } }); return convertView; } } I found this but not getting where and how to use decodeUri in my class
private Bitmap decodeUri(Uri selectedImage) throws FileNotFoundException { BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; BitmapFactory.decodeStream( getContentResolver().openInputStream(selectedImage), null, o); final int REQUIRED_SIZE = 100; int width_tmp = o.outWidth, height_tmp = o.outHeight; int scale = 1; while (true) { if (width_tmp / 2 < REQUIRED_SIZE || height_tmp / 2 < REQUIRED_SIZE) { break; } width_tmp /= 2; height_tmp /= 2; scale *= 2; } BitmapFactory.Options o2 = new BitmapFactory.Options(); o2.inSampleSize = scale; return BitmapFactory.decodeStream( getContentResolver().openInputStream(selectedImage), null, o2); }