Android:如何在点击图像视图时访问父列表项的其他元素
我有一个带有自定义列表项的列表视图,每个列表项在左侧包含一个ImageView,还有3个ImageView标记、交叉和撤消图像。我想在单击勾号、叉号或撤消按钮时更改左侧ImageView的图像。我尝试在适配器中存储listview的引用,并使用了Android:如何在点击图像视图时访问父列表项的其他元素,android,listview,imageview,listadapter,listitem,Android,Listview,Imageview,Listadapter,Listitem,我有一个带有自定义列表项的列表视图,每个列表项在左侧包含一个ImageView,还有3个ImageView标记、交叉和撤消图像。我想在单击勾号、叉号或撤消按钮时更改左侧ImageView的图像。我尝试在适配器中存储listview的引用,并使用了 ImageView imgReturn = (ImageView)lstViewAppr.getChildAt(index).findViewById(R.id.imgPerson) 但是对于某些列表项,getChildStatint返回null。
ImageView imgReturn = (ImageView)lstViewAppr.getChildAt(index).findViewById(R.id.imgPerson)
但是对于某些列表项,getChildStatint返回null。有什么建议吗?在代码中,什么是索引?holder.imgAppr.setonclicklistener新OnClickListener{@Override public void onClickView v{ImageView imgAppr=ImageView v;final int index=Integer imgAppr.getTag;COAAppr objCoa=coaapplist.getindex;ImageView imgPeople=ImageView lstvieppr.getChildAtindex.findviewbydr.id.imgPeople;如果objCoa.getSTATUSTEMP.equalsave{objCoa.setSTATUSTEMP;imgAppr.setImageDrawable C.getResources.getDrawable R.drawable.ic_action_勾选;imgPeople.setImageDrawable C.getResources.getDrawable R.drawable.ic_action_勾选;}};我将索引作为标记存储在适配器的imageview中更改此行:imageview imgReturn=ImageViewlstViewAppr.getChildAtindex.findViewByIdR.id.imgPerson至:imageview imgReturn=ImageViewlstViewAppr.findViewByIdR.id.imgPerson;请将设置索引的代码和此代码添加到问题本身。