Jsoup开发网站客户端第二篇,图片轮播,ScrollView兼容ListView

时间:2024-09-15 09:05:32

最近一段日子忙的焦头烂额,代码重构,新项目编码,导致jsoup开发网站客户端也没时间继续下去,只能利用晚上时间去研究了。今天实现美食网首页图片轮播效果,网站效果图跟Android客户端实现如图:

Jsoup开发网站客户端第二篇,图片轮播,ScrollView兼容ListViewJsoup开发网站客户端第二篇,图片轮播,ScrollView兼容ListView

从浏览器开发者模式可以看到这个轮播图片效果的图片地址以及html连接

Jsoup开发网站客户端第二篇,图片轮播,ScrollView兼容ListView

用节点解析出包含图片url地址(主要代码):

           Elements pics = content.select("#m .pic1");
usedatabase.delete("ScrollView");
for(Element links :pics){
String url = links.attr("src");
}

Jsoup开发网站客户端第二篇,图片轮播,ScrollView兼容ListView

最后用各种开源库实现图片下载,缓存,轮播(以后详细介绍)。

通过自定义ListView,重写OnMeasur方法实现ScrollView兼容ListView滑动效果

 package com.dandan114.Main;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.ListView; public class ListViewTest extends ListView { public ListViewTest(Context context) {
super(context);
// TODO Auto-generated constructor stub
} public ListViewTest(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
public ListViewTest(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
} @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// TODO Auto-generated method stub int expandSpec = MeasureSpec.makeMeasureSpec(
Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, expandSpec);
}
}

Jsoup开发网站客户端第二篇,图片轮播,ScrollView兼容ListView