1

It's weird. I'm frustated with this problem. I saved the data in an ArrayList. when i put the data on RecyclerView. the data is not showing on The list. This is my Code

listOrder.forEach { order ->

                        Log.e(APPConfigs.LOG_TAG,"${order.status} == ${APPConfigs.STATUS_ORDER_BELUM_SIAP}")

                        if(order.status == APPConfigs.STATUS_ORDER_BELUM_SIAP){

                            Log.e(APPConfigs.LOG_TAG," Check : ${order.nama_pemesan}  email : ${order.email_pemesan}")

                            temp.add(order)
                        }

                    }

                    Log.e(APPConfigs.LOG_TAG,"Ready Active Order : temp.size : ${temp.size}")

                    initListOrderAdapter(temp)

That code produce this Log:

BELUM SIAP == BELUM SIAP
2018-12-13 18:51:53.244 4495-4495/galihlprakoso.com.pawonkumerchant E/PAWONKU:  Check : Tony Solala  email : galihlarasprakoso_gmail_com
2018-12-13 18:51:53.244 4495-4495/galihlprakoso.com.pawonkumerchant E/PAWONKU: BELUM SIAP == BELUM SIAP
2018-12-13 18:51:53.244 4495-4495/galihlprakoso.com.pawonkumerchant E/PAWONKU:  Check : Tony Solala  email : galihlarasprakoso_gmail_com
2018-12-13 18:51:53.244 4495-4495/galihlprakoso.com.pawonkumerchant E/PAWONKU: BELUM SIAP == BELUM SIAP
2018-12-13 18:51:53.245 4495-4495/galihlprakoso.com.pawonkumerchant E/PAWONKU:  Check : Tony Solala  email : galihlarasprakoso_gmail_com
2018-12-13 18:51:53.245 4495-4495/galihlprakoso.com.pawonkumerchant E/PAWONKU: BELUM SIAP == BELUM SIAP
2018-12-13 18:51:53.245 4495-4495/galihlprakoso.com.pawonkumerchant E/PAWONKU:  Check : Kidalist  email : jn5990_gmail_com
2018-12-13 18:51:53.245 4495-4495/galihlprakoso.com.pawonkumerchant E/PAWONKU: Ready Active Order : temp.size : 4

It says that my temp variable size is: 4.

And this is My RecyclerViewAdapter Code:

binding.listOrder.adapter = RecyclerViewAdapter<Order,ItemOrderBinding>(listOrders,
                R.layout.item_order, BR.order){ itemOrderBinding ->

            Log.e(APPConfigs.LOG_TAG," Check2 : ${itemOrderBinding.order!!.nama_pemesan}  email : ${itemOrderBinding.order!!.email_pemesan}")

It produces this Log:

Check2 : Tony Solala  email : galihlarasprakoso_gmail_com
2018-12-13 18:51:53.549 4495-4495/galihlprakoso.com.pawonkumerchant E/PAWONKU:  Check2 : Tony Solala  email : galihlarasprakoso_gmail_com
2018-12-13 18:51:53.686 4495-4495/galihlprakoso.com.pawonkumerchant E/PAWONKU:  Check2 : Tony Solala  email : galihlarasprakoso_gmail_com

Only 3? What? What happen in RecyclerView. My Other data is fine with my Own MyRecyclerViewAdapter. This is MyRecyclerViewAdapter:

package galihlprakoso.com.pawonkumerchant.app.adapter

import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.recyclerview.widget.RecyclerView
import android.view.LayoutInflater
import android.view.ViewGroup

class RecyclerViewAdapter<T,B:ViewDataBinding>(var list: List<T>,
                                               val layout_id:Int,
                                               val variable_id:Int,
                                               val onBind:(B)->Unit) : RecyclerView.Adapter<RecyclerViewAdapter<T,B>.RecyclerViewHolder>() {


    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerViewHolder {
        val binding = DataBindingUtil.inflate<B>(LayoutInflater.from(parent.context),
                layout_id,parent,false)


        return RecyclerViewHolder(binding)
    }

    override fun onBindViewHolder(holder: RecyclerViewHolder,position:Int){

        holder.binding.setVariable(variable_id,list[position])

        onBind(holder.binding)

    }

    override fun getItemViewType(position: Int): Int {
        return position
    }

    override fun getItemCount(): Int {
        return list.size
    }



    inner class RecyclerViewHolder(internal var binding: B) : RecyclerView.ViewHolder(binding.root)

}

Please. Help. Thank you!

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Galih laras prakoso
  • 689
  • 2
  • 7
  • 22

1 Answers1

0

It's solved. The problem is on The ScrollView. I put my RecyclerView inside ScrollView.

This stack resolved my problem : RecyclerView inside ScrollView, some items are not shown

Galih laras prakoso
  • 689
  • 2
  • 7
  • 22