我有一个Android应用程序,其中将选定图像的路径存储到SQLite中,并根据文件路径检索它,最后将其设置为imageview。但是,当我在片段之间滚动或滑动时,我的问题就开始了,看起来似乎很漫长。我尝试了一些相关问题,但无法解决此问题。因此,如果有人对我的问题有任何解决方案,那就太好了。
我尝试过的问题:
https://developer.android.com/topic/performance/graphics/load-bitmap
Android - Imageview Fragment laggy
这是我的示例代码,用于将文件路径设置为imageview:
@Override
public void onBindViewHolder(@NonNull ViewHolder viewHolder, int i) {
final FoodItemModel foodItemModel=foodItemModelArrayList.get(i);
viewHolder.itemName.setText(foodItemModel.getItemName());
viewHolder.itemPrice.setText(""+foodItemModel.getItemPrice()+" Tk.");
viewHolder.itemCategory.setText(foodItemModel.getItemCategory());
//Here we are getting the picture path that we stored and then retrieving it and finally decoding it and setting it to imageview
picturePath=foodItemModel.getItemIcon();
Log.v("Path : ",""+picturePath);
viewHolder.itemIcon.setImageBitmap(BitmapFactory.decodeFile(picturePath));
}