Answer the question
In order to leave comments, you need to log in
There is an array with Url images, and there is a recyclerView, how to transfer an image from the array there?
fun getBM(path:String):Bitmap{
val src=path
var url=URL(src)
val connect:HttpURLConnection=url.openConnection() as HttpURLConnection
connect.doInput=true
connect.connect()
val inputStream:InputStream=connect.inputStream
val bitmap:Bitmap=BitmapFactory.decodeStream(inputStream)
return bitmap
}
fun getResizedBitmap(bm: Bitmap, newHeight: Int, newWidth: Int): Bitmap? {
val width = bm.width
val height = bm.height
val scaleWidth = newWidth.toFloat() / width
val scaleHeight = newHeight.toFloat() / height
val matrix = Matrix()
matrix.postScale(scaleWidth, scaleHeight)
return Bitmap.createBitmap(
bm, 0, 0, width, height,
matrix, false
)
document=Jsoup.connect("example").get()
val elementsImg:Elements=document.getElementsByClass("images")
elementsImg.forEach {
bitMapArray.add(getBM(it.attr("src")))
}
bitMapArray.forEach{
newbitMapArray.add(getResizedBitmap(it,100,100)!!)
}
class DataCard(val img: Int, val title:String)
var arrayList1=ArrayList<DataCard>()
// не знаю как передать картинку в arrayList1, я запутался правильно ли вообще делаю, или все-таки через picasso надо было....
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question