在 android 片段中检索 mysql 数据作为 listView

Retrieve mysql data as a listView in an android fragment

我是一个 android 初学者,我正在尝试找到一种方法将数据从 mysql 数据库检索到 ListView,但在片段而不是 Activity。这可能吗?有人可以给我一些建议吗??

是的,这是可能的。您可以在 frgamentLayout 中创建一个 ListView,并使用 findViewById 在片段中使用该列表视图。

然后您可以创建一个函数,其中 returns 来自 mysql 的所有数据作为一个列表,您可以使用适配器将该列表数据设置到 LsiyView。

我已经试过一次了,效果很好。

经过漫长的搜索,我终于找到了解决方案

http://codeoncloud.blogspot.com.es/2013/07/android-mysql-php-json-tutorial.html

我在我的片段中使用了这段代码,它成功了!!!!