Today, it's a simple question to discuss in the group, but the question really needs to be looked at carefully.
problem: Define a simplest arrayadapter, and the ListView in conjunction with the use of the kill item on the display of the simplest textview, a total of 6 item, a screen display 3, encountered the problem is that the program runs, There is no problem with clicking on the 3 item displayed on one screen, but when the swipe is over a screen, the Nullpointer will appear when you click on the item again.
Look at the Onitemlistener, it's written like this:
List.setonitemclicklistener (new Onitemclicklistener () {@Overridepublicvoid int Long = (TextView) list.getchildat (position). Findviewbyid (R.id.text); TV. SetText ("");
The problem is list.getchildat (position). Findviewbyid (), this sentence, when the 4th item is added, the value of position is 4, but the Debug discovery list only 3 child is not empty, So the 4th one is empty, check it out. There is a caching mechanism for the ListView of Android, the ListView only caches the first screen item, and when the item is loaded back, it will only reuse the previous layout. So the maximum number of components stored in the ListView is only the last position of the first screen.
So after the item to want to listen to the normal corresponding, do not look for the control from the ListView, you should click on the view to find, change to View.findviewbyid (), you can.
This simple look: http://www.cnblogs.com/over140/archive/2011/03/23/1991100.html
Android ListView and Arrayadapter