Я пытаюсь получить два комментария к конкретному сообщению, но RecyclerView показывает только один комментарий.
Это мой тест вызовов Api для Почтальона.
![Retrofit](https://i.stack.imgur.com/QT7gJ.png)
Но когда я использую этот вызов в моем приложении, он показывает только один комментарий
Вот следующий код
TwoCommentAdapter:
class TwoCommentsAdapter (var twocommentsList : ArrayList<Comments>) : RecyclerView.Adapter<TwoCommentsAdapter.ViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val itemView = LayoutInflater.from(parent.context).inflate(R.layout.two_comment, parent,false)
return ViewHolder(itemView)
}
override fun getItemCount(): Int {
return twocommentsList.count()
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.comment?.setText(twocommentsList.get(position).comment)
holder.username?.setText(twocommentsList.get(position).username)
}
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
var comment : TextView? = null
var username : TextView? = null
init {
this.comment = itemView.findViewById(R.id.comment_txt)
this.username = itemView.findViewById(R.id.comment_user_txt)
}
}
}
Poko:
class Comments(val comment_id : Int, val username : String, val comment: String)
API Call:
@FormUrlEncoded
@POST("/api/getTwoComment")
fun getTwoComments(@Field("post_id") post_id: Int): Call<ArrayList<Comments>>
Модифицированный вызов в Activity:
getMainApp().swiftAPI.getTwoComments(post_id).enqueue(object : Callback<ArrayList<Comments>>{
override fun onFailure(call: Call<ArrayList<Comments>>?, t: Throwable?) {
Toast.makeText(this@ViewSinglePostActivity, t?.message, Toast.LENGTH_SHORT)
}
override fun onResponse(call: Call<ArrayList<Comments>>?, response: Response<ArrayList<Comments>>?) {
if (response?.isSuccessful!!){
val adapter = TwoCommentsAdapter(response.body()!!)
two_comments_rcv.adapter = adapter
}
}
})
Заранее спасибо.Если хочешь чего-нибудь больного, предоставь