Untitled
unknown
plain_text
13 days ago
798 B
4
Indexable
class ImageGridAdapter(private val context: Context, private val images: ArrayList<Any>) : BaseAdapter() { override fun getCount(): Int = images.size override fun getItem(position: Int): Any = images[position] override fun getItemId(position: Int): Long = position.toLong() override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View { val imageView = ImageView(context) imageView.layoutParams = ViewGroup.LayoutParams(200, 200) imageView.scaleType = ImageView.ScaleType.CENTER_CROP val item = images[position] if (item is Bitmap) { imageView.setImageBitmap(item) } else if (item is Uri) { imageView.setImageURI(item) } return imageView } }
Editor is loading...
Leave a Comment