我无法将解析后的图像放入gridview(我的图像是Bitmap)我需要你的帮助,谢谢。
我有这个扩展BaseAdapter的类,
私有Context mContext; 私人位图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;
}
}
和这个功能: 这是在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
答案 0 :(得分:0)
如果您正在使用User table of parse,那么请按以下方式编写查询:
ParseQuery&lt; ParseUser&GT; query = ParseUser.getQuery();