Skip to main content
added 38 characters in body
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

here is a complex example for your case: Here is a complex example for your case:

List Adapter with ViewHolder Pattern  

noteNote:

  • neverNever use a parameter as a variable (parameters shouldn't be modified!)
  • I like to use an underscore at the beginingbeginning of global fields  (variables,objects objects) names- to better show thetheir scope of them.
  • uYou should make a class name without any special characters and beginning with upper casean uppercase letter.
  • tryTry to get context from the closest possible parameter (as in my example from the parent of getView()the getView() method).
  • The class constructor we defineis defined without a return type! (with name the same name as the class name &and any parameter if You desireyou desire)!
  • forFor later data changes in the adapter u, you can define a method to add items to the list (as inan example  ).

here is a complex example for your case:

List Adapter with ViewHolder Pattern  

note:

  • never use parameter as variable (parameters shouldn't be modified!)
  • I like to use underscore at the begining of global fields(variables,objects) names- to better show the scope of them
  • u should make class name without any special characters and beginning with upper case letter
  • try get context from closest possible parameter (as in my example from parent of getView() method)
  • class constructor we define without return type! (with name the same as class name & any parameter if You desire)
  • for later data changes in adapter u can define method to add items to list (as in example  )

Here is a complex example for your case:

List Adapter with ViewHolder Pattern

Note:

  • Never use a parameter as a variable (parameters shouldn't be modified!)
  • I like to use an underscore at the beginning of global fields  (variables, objects) names to better show their scope.
  • You should make a class name without any special characters and beginning with an uppercase letter.
  • Try to get context from the closest possible parameter (as in my example from the parent of the getView() method).
  • The class constructor is defined without a return type (with the same name as the class name and any parameter if you desire)!
  • For later data changes in the adapter, you can define a method to add items to the list (as an example).
added 77 characters in body
Source Link
ceph3us
  • 146
  • 5

here is a complex example for your case:

List Adapter with ViewHolder Pattern

note:

  • never use parameter as variable (parameters shouldn't be modified!)
  • I like to use underscore at the begining of global fields(variables,objects) names- to better show the scope of them
  • u should make class name without any special characters and beginning with upper case letter
  • try get context from closest possible parameter (as in my example from parent of getView() method)
  • class constructor we define without return type! (with name the same as class name & any parameter if You desire)
  • for later data changes in adapter u can define method to add items to list (as in example )

here is a complex example for your case:

List Adapter with ViewHolder Pattern

note:

  • I like to use underscore at the begining of global fields(variables,objects) names- to better show the scope of them
  • u should make class name without any special characters and beginning with upper case letter
  • try get context from closest possible parameter (as in my example from parent of getView() method)
  • class constructor we define without return type! (with name the same as class name & any parameter if You desire)
  • for later data changes in adapter u can define method to add items to list (as in example )

here is a complex example for your case:

List Adapter with ViewHolder Pattern

note:

  • never use parameter as variable (parameters shouldn't be modified!)
  • I like to use underscore at the begining of global fields(variables,objects) names- to better show the scope of them
  • u should make class name without any special characters and beginning with upper case letter
  • try get context from closest possible parameter (as in my example from parent of getView() method)
  • class constructor we define without return type! (with name the same as class name & any parameter if You desire)
  • for later data changes in adapter u can define method to add items to list (as in example )
Source Link
ceph3us
  • 146
  • 5

here is a complex example for your case:

List Adapter with ViewHolder Pattern

note:

  • I like to use underscore at the begining of global fields(variables,objects) names- to better show the scope of them
  • u should make class name without any special characters and beginning with upper case letter
  • try get context from closest possible parameter (as in my example from parent of getView() method)
  • class constructor we define without return type! (with name the same as class name & any parameter if You desire)
  • for later data changes in adapter u can define method to add items to list (as in example )