如何使用滑动库使用SQLite在gridview中显示图像?

时间:2018-06-19 10:02:46

标签: java android image sqlite android-glide

我有一个SQLite数据库来保存图像。我想将图像显示为网格视图,我想使用滑动库,但我不知道如何使用它

soup = BeautifulSoup(open(xml_file), features="lxml")
tag_list = soup.find_all()
for tag in tag_list:
   try:
       print(tag["name"])
   except:
       pass

这个

  public Bitmap bitmap (byte[] byteImage){
    byte[] outImage = byteImage;
    Bitmap image ;
    if (outImage != null){
        ByteArrayInputStream imageStream = new ByteArrayInputStream(outImage);
        image = BitmapFactory.decodeStream(imageStream);
    }else {
        image= null;
    }
    return image;
}

这是我的适配器

 public byte[] getImageByte(Bitmap bitmap) {
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    byte imageInByte[]=null;
    if(bitmap!=null) {
        bitmap.compress(Bitmap.CompressFormat.JPEG, 50, stream);
        imageInByte=stream.toByteArray();
    }
    return imageInByte;
}

我在每个必须编写的教程中都会看到

public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder = new ViewHolder();

    LayoutInflater inflater = (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    if (convertView==null){

        convertView = inflater.inflate(R.layout.item_produk, null);

        holder.txtNama = (TextView) convertView.findViewById(R.id.tvnmproduk);
        holder.txtHarga = (TextView) convertView.findViewById(R.id.tvharga);
        holder.imageView = (ImageView) convertView.findViewById(R.id.imgproduk);
        convertView.setTag(holder);
    }else {
        holder = (ViewHolder) convertView.getTag();
    }

    ModelProduk modelProduk = produklist.get(position);

    holder.txtNama.setText(modelProduk.get_nama());
    holder.txtHarga.setText(Integer.toString(modelProduk.get_harga()));

    /*byte[] produkimage = modelProduk.get_gambar();
    Bitmap bitmap = BitmapFactory.decodeByteArray(produkimage, 0 , produkimage.length);*/
    holder.imageView.setImageBitmap(bitmap(modelProduk.get_gambar()));


    return convertView;

但我不知道该代码放在哪里

1 个答案:

答案 0 :(得分:2)

使用此

<script type="text/javascript">
    var url = window.location.href;
    var racine = url.substring(0, url.lastIndexOf("/"));
    var page = url.substring(url.lastIndexOf("/")+1);

    if(page == "#old_url.html"){
        document.location.href = racine + "/new_url.html";
    }
</script>