'Put pdf files which I download from Firebase Cloud Storage to recyclerview using Kotlin
I have prepared recyclerview to show pdf files but when I try some functions to put pdfs into recyclerview they didin't show. Is any function to do this?
This is my adapter and here probably all is well
class AdapterKarty(private val fileList: ArrayList<plik>): RecyclerView.Adapter<AdapterKarty.ViewHolder>(){
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AdapterKarty.ViewHolder {
val a = LayoutInflater.from(parent.context).inflate(R.layout.karta_pliku,parent, false)
return ViewHolder(a);
}
override fun onBindViewHolder(holder: AdapterKarty.ViewHolder, position: Int) {
var item = fileList[position]
holder.dokument.text = item.Name
}
override fun getItemCount(): Int {
return fileList.size
}
inner class ViewHolder(itemView: View): RecyclerView.ViewHolder(itemView){
var dokument: TextView = itemView.tv_dokment
}
}
In list I use class plik where i declare only name because here i try put name of pdf
class plik( var Name: String?=null){
}
And here I have my main class where I try put those files to recyclerview
class Dokumenty : AppCompatActivity() {
private var stor: FirebaseStorage?=null
private var storageReference = stor?.reference
lateinit var recyclerView: RecyclerView
private lateinit var listaPlikow : ArrayList<plik>
private lateinit var myAdapter: AdapterKarty
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_dokumenty)
stor = FirebaseStorage.getInstance()
recyclerView = findViewById(R.id.recyclerView)
recyclerView.layoutManager = LinearLayoutManager(this)
recyclerView.setHasFixedSize(true)
listaPlikow = arrayListOf()
myAdapter = AdapterKarty(listaPlikow)
getFiles()
}
private fun getFiles() {
var pliki = storageReference?.child("Pliki/")
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
