webview的展示和轮播图
@Override
//详情
public void showData_Detail(final Detail_Bean detail_bean) {
runOnUiThread( new Runnable() {
@Override
public void run() {
//Toast.makeText( DetailActivity.this, ""+detail_bean.getMessage(), Toast.LENGTH_SHORT ).show();
Detail_Bean.ResultBean detail_list = detail_bean.getResult();
tv_DetailName.setText( detail_list.getCommodityName() );//给name赋值
tv_DetailPrice.setText( "¥" + detail_list.getPrice() );//给价格赋值
tv_DetailSold.setText( "已售" + detail_list.getSaleNum() + "件" );//销量
tv_DetailWeight.setText( detail_list.getWeight() + "kg" );//重量
//加载webview商品详情
String details = detail_list.getDetails();//webview详情页面
WebSettings webSettings = wv_Detail.getSettings();
webSettings.setJavaScriptEnabled( true );//设置WebView属性,能够执行Javascript脚本
webSettings.setBuiltInZoomControls( true ); //设置支持缩放
String s2 = "<script type=\"text/javascript\">" +
"var imgs=document.getElementsByTagName('img');" +
"for(var i = 0; i<imgs.length; i++){" +
"imgs[i].style.width='100%';" +
"imgs[i].style.height='auto';" +
"}" +
"</script>";
wv_Detail.loadDataWithBaseURL( null, details + s2 + "<html><body>", "text/html", "utf-8", null );
//设置轮播图片
String picture = detail_list.getPicture();
split = picture.split( "\\," );
pic = split[0].toString();
for (int i = 0; i < split.length; i++) {//循环添加图片
tupian_list.add( split[i] );
}
//给轮播设置数据
detailBanner.setPages( tupian_list, new MZHolderCreator<BannerViewHolder>() {
@Override
public BannerViewHolder createViewHolder() {
return new BannerViewHolder();
}
} );//给轮播设置数据
}
} );
}//详情
//轮播适配器
public static class BannerViewHolder implements MZViewHolder<String> {
private ImageView mImageView;
@Override
public View createView(Context context) {
// 返回页面布局
View view = LayoutInflater.from( context ).inflate( R.layout.banner_item, null );
mImageView = (ImageView) view.findViewById( R.id.banner_image );
return view;
}
@Override
public void onBind(Context context, int i, String s) {
//glide加载图片
Glide.with( context ).load( s ).into( mImageView );
}
}//轮播适配器