dimanche 29 novembre 2020

Getting *NoSuchMethodException* when method defiantly is part of the class

I have the following class:

   class CountryDataItem (id: Long?, private val countryName :String?, private var countryFlagUrl : String?,
 var gameCount : Int,  var liveCount:Int)
    : BaseDataItem(id) {

    companion object {

        fun onCreateViewHolder(
            parent: ViewGroup,
            onRecyclerItemClickListener: OnRecyclerItemClickListener?
        ): RecyclerView.ViewHolder {
            val view: View =
                LayoutInflater.from(parent.context).inflate(R.layout.country_item, parent, false);
        }
    }
}

But when running:

  someKClass.java.getMethod("onCreateViewHolder",parent.javaClass,
                                onRecyclerItemClickListenerRef.get()?.javaClass)

I'm getting the exception. Can't understand why Maybe the reason related to the fact the the method is "static" but in java getMethod returned also static methods





Aucun commentaire:

Enregistrer un commentaire