android - What difference between static and non static viewholder in RecyclerView Adapter? -


what advantages of approach (using static nested class in class myadapter extends recyclerview.adapter):

static class myvh extends recyclerview.viewholder {...} 

and approach (using member inner class):

  class myvh extends recyclerview.viewholder {...} 

or doesn't affect performance , both approaches used?

it more java question android question. recommended use static inner classes avoid memory leaks if take instances out of class. can have @ this awesome post explains memory leaks on inner classes.

basically nyx says:

  • if declare viewholder static can reuse in other adapters. anyway, not recommend it, create new separated class , use multiple places, make more sense. 1 class 1 purpose.
  • in case of view holders, classes used inside adapter, instances should not go fragment or activity or elsewhere definition. means having static or non-static, in case of view holders, same.

answering performance question, can have @ this answer. static 1 take less memory other one, again, talking recyclers recycle instances, memory impact not problem.


Comments

Popular posts from this blog

java - HTTP Status 500 - An exception occurred processing JSP page /second.jsp at line 15 -

php - Using str_replace to translate a MySQL Table in html -

asp.net mvc - Cannot display error message on Editor or EditorFor -