我想从mysql db加载有限数量的结果到回收视图,当列表到达底部时,它应该再加载10个结果。
这是我的php:
<?php
//Creating a connection
$con = mysqli_connect("localhost:3306","root","","story-db");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
/*Get the id of the last visible item in the RecyclerView from the request and store it in a variable. For the first request id will be zero.*/
$sql= "Select * from story_table order by elapsed desc";
$result = mysqli_query($con ,$sql);
while ($row = mysqli_fetch_assoc($result)) {
$array[] = $row;
}
header('Content-Type:Application/json');
echo json_encode($array);
mysqli_free_result($result);
mysqli_close($con);
我正在查询和排序数据,但我不想一次加载所有100个条目。我要10乘10进入我的回收视图
如何使用侦听器的名称,以及如何实现它?
发布于 2018-07-12 15:36:05
你可以在数据库中使用分页系统,你应该在数据库中放置一个参数“page”,例如在第1页中存储10个数据条目,然后在第2页中存储下10个数据条目。因此,你可以使用以下方法从数据库中获取有限数量的数据Endless ScrollListener使用“页面”。
https://stackoverflow.com/questions/-100005573
复制相似问题