【发布时间】:2015-10-30 19:26:57
【问题描述】:
今天刚开始使用此服务,文档有点混乱。
我使用照片库模板创建了一个Space。在这个空间中,我有图像、作者和照片库类型的条目。我的问题是,如何检索图像以在我的 android 应用中显示?
要与Contentful Delivery API 交互,我知道我必须使用CDAClient 对象和CDAEntry 对象来获取我想要获取的条目。
我在Fragment 类的onCreate() 方法中定义了这个,如下所示:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mContext = getActivity();
client = CDAClient.builder()
.setSpace("id-of-the-space-am-accessing")
.setToken("the-access-token")
.build();
entry = client.fetch(CDAEntry.class).one("the id of the image I want to retrieve");
}
在onCreateView() 方法中,我尝试这样查看结果:
Log.e(TAG, "Result: " + entry.toString());
当我运行应用程序时,我在 Logcat 中得到了这个:
E/NEWS ACTIVITY﹕ Result: CDAEntry{id='2YhtjbebgscIwO2keYEa4O'}
此 id 与我传递给 client.fetch(CDAEntry.class).one() 的图像的 id 匹配
显然正在获取图像,但如何显示它?
【问题讨论】:
标签: android contentful