Android 单击时更新ViewHolder值,而不更新ListView中的内容列表
当我单击ListView行时,是否可以更新文本 不重新初始化所有内容列表 以下代码中的notifyDataSetChanged不起作用:Android 单击时更新ViewHolder值,而不更新ListView中的内容列表,android,listview,Android,Listview,当我单击ListView行时,是否可以更新文本 不重新初始化所有内容列表 以下代码中的notifyDataSetChanged不起作用: override fun selectView(chosenItemView: View?) { chosenItemView?.setBackgroundColor(Color.TRANSPARENT) val item = chosenItemView?.tag as ListAdapter.MyHolder // right i
override fun selectView(chosenItemView: View?) {
chosenItemView?.setBackgroundColor(Color.TRANSPARENT)
val item = chosenItemView?.tag as ListAdapter.MyHolder // right item found
item.name.text = "Another text when on clicked"
adapter.notifyDataSetChanged()
}
利用适配器的
notifyItemInserted(int位置)
@codefeaknotifyItemInserted
是RecyclerView。适配器方法,而不是ListView抱歉,我的意思是尝试切换到RecyclerView并使用上述方法。利用适配器的notifyItemInserted(int位置)
@codefeaknotifyItemInserted
是RecyclerView.Adapter方法,而不是ListView抱歉,我的意思是尝试切换到RecyclerView并使用上述方法。