java.lang.IllegalArgumentException: Parameter specifIEd as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter convertVIEwAdapter.getVIEw at androID.Widget.AbsListVIEw.obtainVIEw(AbsListVIEw.java:2346) at androID.Widget.ListVIEw.makeAndAddVIEw(ListVIEw.java:1876) at androID.Widget.ListVIEw.fillDown(ListVIEw.java:702) at androID.Widget.ListVIEw.fillFromtop(ListVIEw.java:763) at androID.Widget.ListVIEw.layoutChildren(ListVIEw.java:1671) at androID.Widget.AbsListVIEw.onLayout(AbsListVIEw.java:2148)
这是androID的logcat.
我尝试使用Java正常工作的基本适配器,在Adapter或其他适配器中出了点问题.
我尝试使用公共构造函数,并且发现数组列表计数3已检查.总是在getVIEw崩溃
MyAdapter代码::
inner class MyAppAdapter constructor(private val parkingList: ArrayList<App>, private val mContext: Context) : BaseAdapter() { overrIDe fun getCount(): Int { return this.parkingList.size } overrIDe fun getItem(position: Int): Any { return position } overrIDe fun getItemID(position: Int): Long { return position.tolong() } overrIDe fun getVIEw(position: Int, convertVIEw: VIEw, parent: VIEwGroup): VIEw? { val vIEwHolder: VIEwHolder var rowVIEw: VIEw? = convertVIEw if (rowVIEw == null) { rowVIEw = LayoutInflater.from(mContext).inflate(R.layout.item_more_apps, parent, false) vIEwHolder = VIEwHolder() vIEwHolder.appIcon = rowVIEw.findVIEwByID(R.ID.appIcon) vIEwHolder.appname = rowVIEw.findVIEwByID(R.ID.appname) vIEwHolder.appDescription = rowVIEw.findVIEwByID(R.ID.appDescription) rowVIEw.tag = vIEwHolder } else { vIEwHolder = convertVIEw.tag as VIEwHolder } vIEwHolder.appname!!.text = String.format("%s", this.parkingList[position].name) vIEwHolder.appDescription!!.text = String.format("%s", this.parkingList[position].description) GlIDe.with(applicationContext).load(this.parkingList[position].icon).into(vIEwHolder.appIcon!!) rowVIEw?.setonClickListener { try { startActivity(Intent("androID.intent.action.VIEW", Uri.parse("market://details?ID=" + this@MyAppAdapter.parkingList[position].link))) } catch (e: ActivityNotFoundException) { startActivity(Intent("androID.intent.action.VIEW", Uri.parse("http://play.Google.com/store/apps/details?ID=" + this@MyAppAdapter.parkingList[position].link))) } } return rowVIEw } inner class VIEwHolder { var appDescription: TextVIEw? = null var appIcon: ImageVIEw? = null var appname: TextVIEw? = null } }
在AsyncTask中使用-> onPostExecute
myAppAdapter = MyAppAdapter(appArrayList, applicationContext) lvPoses!!.adapter = myAppAdapter
像这样清除变量
lateinit var myAppAdapter: MyAppAdapter private val appArrayList = ArrayList<App>() private var lvPoses: ListVIEw? = null
解决方法:
如果尚未创建视图,则convertVIEw可以为null.修复参数声明:
overrIDe fun getVIEw(position: Int, convertVIEw: VIEw?, parent: VIEwGroup): VIEw? {...}
总结 以上是内存溢出为你收集整理的Adapter.getView上的参数convertView上的IllegalArgumentException全部内容,希望文章能够帮你解决Adapter.getView上的参数convertView上的IllegalArgumentException所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)