Switch changes ON-OFF when scrolled in Listview Android
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a ListView with a switch. Whenever I turn the switch ON and scroll down and scroll it back up, the switch changes to the turned OFF state. 回答1: Put this in your custom adapter.. // THESE TWO METHODS ALLOWS SCROLLABLE WITHOUT SWITCHES BEING TURNED ON/OFF WHEN VIEWS ARE RECYCLED // these methods in fact tell the adapter to not recycle the rows so might slow down process @Override public int getViewTypeCount() { return getCount(); } @Override public int getItemViewType(int position) { return position; } 回答2: I have faced this problem