WebView展示商品详情

点击获取id跳转详情页

pzshAdapter.setClick(new PzshAdapter.click() {
         @Override
         public void click(View view, int position) {
               Toast.makeText(getActivity(),"点击",Toast.LENGTH_LONG).show();
                 //点击跳转到详情页
                  Intent intent = new Intent(getActivity(), HomeGoodsActivity.class);
                  int gid = pzshlist.get(position-1).getCommodityId();  //获取id
                  String s = String.valueOf(gid);   
                  intent.putExtra("gid",s);
                  startActivity(intent);
                  Toast.makeText(getActivity(),gid+"",Toast.LENGTH_LONG).show();
              }
          });

webview交互

//------------------------------------------------网页------------------------------------------------------
                //可以设置支持缩放
                webview.getSettings().setSupportZoom(true);
                //设置扩大比列的缩放
                webview.getSettings().setUseWideViewPort(true);
                webview.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
                webview.getSettings().setLoadWithOverviewMode(true);
                webview.setWebChromeClient(new WebChromeClient());
                webview.loadDataWithBaseURL(null, goodlist.getDetails(), "text/html", "utf-8", null);

                //获取详请的名字  价格  数量    然后赋值
                String commodityName = goodlist.getCommodityName();
                xqTitle.setText(commodityName);

                int price = goodlist.getPrice();
                xqPrice.setText("¥" + price);

                int saleNum = goodlist.getSaleNum();
                xqXnum.setText("销量:" + saleNum);

                //--------------------------------------------图片展示-----------------------------------------------

                //获取图片
                String picture = goodlist.getPicture();
                String[] strings = picture.split(",");   //剪切

                //新建一个存放网络图片的集合  string类型
                imageUrl = new ArrayList<>();
                for (int i = 0; i < strings.length; i++) {    //flybanner展示
                    imageUrl.add(strings[i]);
                    imageUrl.get(i);
                }
                xq_banner.setImagesUrl(imageUrl);
            }

        });

你可能感兴趣的:(WebView展示商品详情)