我想从Parse.com的默认用户类中检索图像。我只想要名为“Image”的列中的值。
ParseUser currentuser = ParseUser.getCurrentUser();
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("following");
query.whereEqualTo("username", currentuser);
try {
ob = query.find();
} catch (ParseException e) {
e.printStackTrace();
}
“图片”是列名。
for (ParseObject user : ob) {
// Locate images in pic column
image = (ParseFile) user.get("Image");
}
如何应用循环来获取列表中的所有图像文件?
image.getDataInBackground(new GetDataCallback() {
public void done(byte[] data, ParseException e) {
if (e == null) {
Bitmap pictureBitMap = BitmapFactory.decodeByteArray(data, 0, data.length);
img.setImageBitmap(pictureBitMap);
listView.setAdapter(new myCustomList(MainActivity.this));
} else {
// something went wrong
}
}
});
答案 0 :(得分:0)
考虑使用Universal Image Loader(UIL)这样的开源库,这样您就不必大量下载将其转换为Bitmap并将其设置为imageView的文件。
基本上你可以从parseFile中检索网址
ListBox
在UIL中只需传递url和imageView
即可 public static SqlDataReader ExecuteReader(String connectionString, String commandText,
CommandType commandType, params SqlParameter[] parameters) {
SqlConnection conn = new SqlConnection(connectionString);
using (SqlCommand cmd = new SqlCommand(commandText, conn)) {
cmd.CommandType = commandType;
cmd.Parameters.AddRange(parameters);
conn.Open();
// When using CommandBehavior.CloseConnection, the connection will be closed when the
// IDataReader is closed.
SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);
return reader;
}
}