Skip to content

Instantly share code, notes, and snippets.

@xxxzhi
Last active October 20, 2016 02:28
Show Gist options
  • Save xxxzhi/7243697 to your computer and use it in GitHub Desktop.
Save xxxzhi/7243697 to your computer and use it in GitHub Desktop.
use handler to deal with the invalid when setVisibility(View.GONE). At most time ,if the view is under use,setVisibility will be useless.
Message.obtain(handler,new Runnable() {
@Override
public void run() {
System.out.println("gone");
viewGroup.getChildAt(i).clearAnimation(); // this is very imporant! clear animation
for(int i=0;i!=viewGroup.getChildCount();++i){
if(viewGroup.getChildAt(i).getId() == id){
viewGroup.getChildAt(i).setVisibility(View.VISIBLE);
}else{
viewGroup.getChildAt(i).setVisibility(View.GONE);
}
}
}
}).sendToTarget();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment