1
对于我的android应用程序,我希望使用JSON将来自远程MySQL数据库的图像加载到库视图。 是否可能。如何在Android中使用JSON从MySQL中检索图像?
可能意味着任何一个帮助我在此基础上的一些示例代码
对于我的android应用程序,我希望使用JSON将来自远程MySQL数据库的图像加载到库视图。 是否可能。如何在Android中使用JSON从MySQL中检索图像?
可能意味着任何一个帮助我在此基础上的一些示例代码
这是可能的。首先,您需要获取保存在远程服务器中的图像URL。这可以通过使用JSON或任何其他模式的api调用来实现。通过该api,您可以检索保存在远程数据库上的图像URL。获得所有图像网址后,您可以使用Lazy load of images in ListView加载图像。在惰性加载代码,他们已经用在布局一个ListView,因此图像和相应的文字显示为列表项,您可以在ListView控件更改为画廊是这样的:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Gallery android:id="@+id/gallery" android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Clear Cache"/>
</LinearLayout>
我认为这将让你期望的结果。