Original translated from: http://www.cxyclub.cn/n/16666/
After implementing the fade-out effect in Android development, the viewgroup is called in the onanimationend method when an image control is removed from the interface. removeview: It took me a long time to solve the nullpointerexception problem and finally found a solution in a foreigner's forum.
The direct execution method is usually as follows:
@ Override
Public void onanimationend (animation arg0 ){
// Remove the image when the animation ends.
Viewgroup. removeview (imageview );
}
However, the NULL pointer nullpointerexception may occur.
Later, we can see that the foreigner's method is to use handler to handle it, so no exception is reported, as shown below:
@ Override
Public void onanimationend (animation arg0 ){
// Remove the image when the animation ends.
// Viewgroup. removeview (imageview );
New handler (). Post (New runnable (){
Public void run (){
Viewgroup. removeview (imageview );
}
});
}
I would like to record it and hope it will be helpful to you.
Original translated from: http://www.cxyclub.cn/n/16666/