直接贴代码吧
public class LeanCloudHelper {
//连上数据库
public void link() {
AVOSCloud.initialize(MyApplication.getContext(),
"appid",
"appkey",
"serverURL");
}
//设置textview
public void setText(String className, String ObjectId, final String key, final TextView textView) {
AVQuery<AVObject> query = new AVQuery<>(className);
query.getInBackground(ObjectId).subscribe(new Observer<AVObject>() {
public void onSubscribe(Disposable disposable) {}
public void onNext(AVObject avObject) {
String value= avObject.getString(key);
textView.setText(value);
}
public void onError(Throwable throwable) {}
public void onComplete() {}
});
}
//设置imageview
public void setImage(String className, String ObjectId, final String key, final ImageView imageView) {
AVQuery<AVObject> query = new AVQuery<>(className);
query.getInBackground(ObjectId).subscribe(new Observer<AVObject>() {
public void onSubscribe(Disposable disposable) {}
public void onNext(AVObject avObject) {
String web= avObject.getString(key);
Glide.with(imageView).load(web).into(imageView);
}
public void onError(Throwable throwable) {}
public void onComplete() {}
});
}
}
来源:CSDN
作者:石乐志同志
链接:https://blog.csdn.net/weixin_42622103/article/details/104617139