Android: Dynamically change Image in Listview

前端 未结 5 2019
傲寒
傲寒 2021-02-04 07:08

I have a listview defined by the following xml. I need to toggle the image in the list during runtime when the user clicks on any row. How can I achieve this? A

5条回答
  •  独厮守ぢ
    2021-02-04 08:05

        listview.setOnItemClickListener(new AdapterView.OnItemClickListener(){
    
            public void onItemClick(AdapterView arg0, View arg1, int arg2,
                    long arg3) {
                ImageView imageView=arg1.findViewById(R.id.img);
                imageView.setImageResource(R.drawable.new_image);
    
            }
    
        });
    

提交回复
热议问题