Android 从解析数据库检索图像
我已经在parse数据库上发布了我的信息,但我想使用recircularView检索它。 谁能指导我或指导我该怎么做 下面是我保存再循环视图布局的xml代码Android 从解析数据库检索图像,android,parse-platform,android-recyclerview,data-retrieval,Android,Parse Platform,Android Recyclerview,Data Retrieval,我已经在parse数据库上发布了我的信息,但我想使用recircularView检索它。 谁能指导我或指导我该怎么做 下面是我保存再循环视图布局的xml代码 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layo
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/size_byte"
android:layout_marginLeft="@dimen/size_word"
android:layout_marginRight="@dimen/size_word"
android:layout_marginTop="@dimen/size_byte">
<ImageView
android:id="@+id/adPic"
android:layout_width="@dimen/movie_thumbnail_width"
android:layout_height="@dimen/movie_thumbnail_height"
android:layout_centerVertical="true"
android:src="@mipmap/ic_launcher" />
<TextView
android:id="@+id/adTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/adPic"
android:layout_marginLeft="56dp"
android:alpha="0.87"
android:gravity="right"
android:padding="@dimen/size_half_byte"
android:text="Hitman Agent 47"
android:textSize="@dimen/size_text_primary" />
<TextView
android:id="@+id/adPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@id/adTitle"
android:alpha="0.87"
android:padding="@dimen/size_half_byte"
android:text="5.00$"
android:textSize="@dimen/size_text_secondary" />
<TextView
android:id="@+id/adDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@id/adPrice"
android:alpha="0.87"
android:padding="@dimen/size_half_byte"
android:text="31-31-31"
android:textSize="@dimen/size_text_secondary" />
</RelativeLayout>
您可以使用ParseFile的getUrl()方法从ParseObject获取图像url 假设您得到一个类似这样的ParseObject列表
List<MyObject> myObjects = nee ArrayList();
List<ParseObject> objects
for (ParseObject objectItem: objects) {
String fileName = "";
String fileURL = "";
if (objectItem.getParseFile("imageColumn") != null) {
try {
ParseFile parseFile = (ParseFile) objectItem
.getParseFile("imageColumn");
fileURL = parseFile.getUrl();
fileName = parseFile.getName();
myObjects.add(new MyObject(fileName,fileURL));
} catch (Exception e) {
}
}
}
List myObjects=nee ArrayList();
列出对象
for(ParseObject对象项:对象){
字符串fileName=“”;
字符串fileURL=“”;
if(objectItem.getParseFile(“imageColumn”)!=null){
试一试{
ParseFile ParseFile=(ParseFile)objectItem
.getParseFile(“imageColumn”);
fileURL=parseFile.getUrl();
fileName=parseFile.getName();
添加(新的MyObject(文件名,fileURL));
}捕获(例外e){
}
}
}
稍后在getView中,使用文件URL仅获取listview中可见项的图像。这样您的listview就不会崩溃。检索图像与RecyclerView无关。是的,对不起,下面发布的代码是在您发布代码之前发布的。没问题,James,谢谢我需要使用ArrayList吗?我能不能在parseObject中获取每个广告的信息并将其放入recyclerview?为什么不能,这是你的愿望:)如果你能做到,你能告诉我并更新你的答案,以便我能接受它吗。