简体   繁体   中英

i need to retrieve images from parse to GridView

i cant put my images from the parse into the gridview (my images is Bitmap) i need your help, thank.
i have this class that extends BaseAdapter,

private Context mContext; private Bitmap btimaprecieve;

public CustomGrid(Context c ) {
    mContext = c;

}

//---returns the number of images---
public int getCount() {
    return imageId.length;
}

//---returns the ID of an item---
public Object getItem(int position) {
    return imageId[position];
}

public long getItemId(int position) {
    return position;
}

//---returns an ImageView view---
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.setLayoutParams(new GridView.LayoutParams(85, 85));
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        imageView.setPadding(8, 8, 8, 8);
    } else {
        imageView = (ImageView) convertView;
    }

    imageView.setImageResource(imageId[position]);

    return imageView;
}




private Integer [] imageId = {

        R.drawable.tor,
        R.drawable.tor,
        R.drawable.tor
};
public Bitmap add(Bitmap bitmap_recieve) {
    return btimaprecieve;
}

}

and this function: this is in the MainActivity

GridView gridview = (GridView)findViewById(R.id.grid);
     myImageAdapter= new CustomGrid(this);
    gridview.setAdapter( myImageAdapter);

public void PullImage(){
progressDialog = ProgressDialog.show(this, "", "Downloading Image...", true);

    ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("User");
    //  query.whereEqualTo("Column", bitmap);
    query.getFirstInBackground(new GetCallback<ParseObject>() {
        public void done(ParseObject object, ParseException e) {
            if (object != null) {

                ParseFile file = (ParseFile) object.get("ImageFile");

                file.getDataInBackground(new GetDataCallback() {


                    public void done(byte[] data, ParseException e) {
                        if (e == null) {

                            bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);


                                    progressDialog.dismiss();
                        } else {
                        }
                    }
                });

            } else {
                Toast.makeText(getApplicationContext(), "Exception", Toast.LENGTH_SHORT).show();

            }
        }
    });
}

logcat:

06-22 15:36:30.979  10694-10694/? I/art﹕ Late-enabling -Xcheck:jni
06-22 15:36:31.168  10694-10729/com.example.tepper.gridview D/OpenGLRenderer﹕ Render dirty regions requested: true
06-22 15:36:31.176  10694-10694/com.example.tepper.gridview D/Atlas﹕ Validating map...
06-22 15:36:31.220  10694-10729/com.example.tepper.gridview I/Adreno-EGL﹕ <qeglDrvAPI_eglInitialize:410>: QUALCOMM Build: 10/24/14, 167c270, I68fa98814b
06-22 15:36:31.222  10694-10729/com.example.tepper.gridview I/OpenGLRenderer﹕ Initialized EGL, version 1.4
06-22 15:36:31.240  10694-10729/com.example.tepper.gridview D/OpenGLRenderer﹕ Enabling debug mode 0

If you are using User table of parse then write query like this:

ParseQuery < ParseUser> query = ParseUser.getQuery();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM