notifyDataChanged()无法更新可扩展列表视图数据

我正在开发一个可扩展的列表视图,当我创建一个奖励广告后,我想在用户观看奖励的广告之后添加一个可展开的列表视图,但应用程序崩溃的Android监视器错误。 这里是代码…

class MainActivity : Activity(),RewardedVideoAdListener { override fun onRewardedVideoAdClosed() = Unit override fun onRewardedVideoAdLeftApplication() = Unit override fun onRewardedVideoAdLoaded() = Unit override fun onRewardedVideoAdOpened() = Unit override fun onRewarded(rewardedLiterature: RewardItem?) { rewardedLiterature.apply { ParentList.add("New Articles") ParentList.reverse() } } override fun onRewardedVideoStarted() = Unit override fun onRewardedVideoAdFailedToLoad(p0: Int) { Toast.makeText(this,"Please try again",Toast.LENGTH_SHORT).show() } private lateinit var childlist: MutableList private lateinit var ParentListItems: MutableMap<String, List> private lateinit var expandabilityView: ExpandableListView private var ParentList: MutableList = ArrayList() ) private var poems = arrayOf("Five","Six","Seven") private var LoveName = arrayOf("Eight","Nine","Ten","Eleven") private var moreLiterature = arrayOf("ZOne","zTwo","ZThree") private var ByDefaultMessage = arrayOf("Items Loading") private lateinit var mRewardedVideoAd : RewardedVideoAd init { ParentList.add("Letters") ParentList.add("Poems") ParentList.add("Let's Chill!") } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this) mRewardedVideoAd.rewardedVideoAdListener = this loadRewardedVideoAd() val moreContentButton = findViewById(R.id.moreContents) moreContentButton.setOnClickListener{ if (mRewardedVideoAd.isLoaded) { mRewardedVideoAd.show() } } ParentListItems = LinkedHashMap() for (HoldItem in ParentList) { when (HoldItem) { "Letters" -> loadChild(funnyLiterature) "Poems" -> loadChild(poems) "Let's Chill!" -> loadChild(LoveName) "New Articles" -> loadChild(moreLiterature) else -> loadChild(ByDefaultMessage) } ParentListItems.put(HoldItem, childlist) } expandabilityView = findViewById(R.id.expandableListView1) val expListAdapter = ListAdapter( this, ParentList, ParentListItems) expandabilityView.setAdapter(expListAdapter) expListAdapter.notifyDataSetChanged() expandabilityView.setOnChildClickListener {_, _, groupPosition, childPosition, _ -> val selected = expListAdapter.getChild( groupPosition, childPosition) as String val intent = Intent(this@MainActivity, DetailActivity::class.java) when (selected) { "ማትስ ተማሪ ለፍቅረኛዋ የፃፈችዉ ደብዳቤ" -> titleOfContent = detailContents[0] "የህግ ተመራቂ ለፍቅረኛዉ የፃፈዉ መልእክት" -> titleOfContent = detailContents[1] "የ‹ለምን አንተን ወደድኩህ?›ፍልስፍና" -> titleOfContent = detailContents[2] "አጭር መልእክት" -> titleOfContent = detailContents[3] } private fun loadRewardedVideoAd() = mRewardedVideoAd.loadAd("ca-app-pub-xxxxxxx", AdRequest.Builder().build()) private fun loadChild(ParentElementsName: Array) { childlist = ArrayList() for (model in ParentElementsName) childlist.add(model) } companion object { internal var titleOfContent: String ?= null private var detailContents = arrayOf("This","Is","a","Test") 

这里是适配器类

  class ListAdapter(private val context: Activity, private val Items: List, private val ParentListItems: Map<String, List>) : BaseExpandableListAdapter() { override fun getChild(groupPosition: Int, childPosition: Int): Any = ParentListItems[Items[groupPosition]]!![childPosition] override fun getChildId(groupPosition: Int, childPosition: Int): Long = childPosition.toLong() override fun getChildView(groupPosition: Int, childPosition: Int, isLastChild: Boolean, ListView: View?, parent: ViewGroup): View { var myListView = ListView val contentPosition = getChild(groupPosition, childPosition) as String val inflater = context.layoutInflater if (myListView == null) myListView = inflater.inflate(R.layout.child_list_item, null) val item = myListView!!.findViewById(R.id.textView1) item.text = contentPosition return myListView } override fun getChildrenCount(groupPosition: Int): Int = ParentListItems[Items[groupPosition]]!!.size override fun getGroup(groupPosition: Int): Any = Items[groupPosition] override fun getGroupCount(): Int = Items.size override fun getGroupId(groupPosition: Int): Long = groupPosition.toLong() override fun getGroupView(groupPosition: Int, isExpanded: Boolean, ListView: View?, parent: ViewGroup): View { var myListView= ListView val allContents = getGroup(groupPosition) as String if (myListView == null) { val textInflater = context .getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater myListView = textInflater.inflate(R.layout.parent_list_item, null) } val item = myListView!!.findViewById(R.id.textView1) item.text = allContents return myListView } override fun hasStableIds(): Boolean = true override fun isChildSelectable(groupPosition: Int, childPosition: Int): Boolean = true } 

Android监视器说,在getChildrenCount函数的Adapter类中findKotlin NullPoint Exception