1

I got one piece of code to study and I was puzzled for a long time because I tried to make my own version of it and it broke then I tried commenting the original code step by step to see when it failed and it gave me a null pointer in a getView method after I commented the declaration of one variable it used. I wasn't seeing this method being called anywhere and searched a lot for an answer until I found this:

When is the getView() method of ListView called?

It esentially says that getView getts called whenever an item is passed to the adapter through the setAdapter method.

I look all over the View docs, Adapter docs, Inflater, etc and couldn't find any piece of information to tell me that this happened, not even the setAdapter method itself says anything about this behavior. Is this just a documentation error or is there some general guideline I'm not following correctly?

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
Thiago
  • 746
  • 1
  • 10
  • 22
  • 1
    Better search on youtube "world of listview" or something like this (google io 2010 session) – Selvin Jul 17 '13 at 19:05
  • 2
    SImply put, the Javadoc isn't the documentation- its a functional reference. The documentation is in the rest of the site. Javadoc is NEVER full documentation, nor is that its purpose. – Gabe Sechan Jul 17 '13 at 19:05
  • Some aspects of the Android documentation offer excellent coverage of a subject. Some aspects of the Android documentation offer craptastic coverage of a subject. `AdapterView`, its subclasses, and the `ListAdapter` family, falls in the craptastic bucket, IMHO. The SDK samples, Google I|O presentations, and such certainly help. However -- at the risk of being completely self-serving -- this is why many Android developers elect to grab a book to supplement the official documentation. – CommonsWare Jul 17 '13 at 19:10
  • Just put a log in the getView method and you will see that it is called when the list is shown for the first time and when you start scrolling. – Hoan Nguyen Jul 17 '13 at 19:12
  • This is weird: To log I just add in the class: private static final String TAG = "test"; and 1st line of getView I just added Log.i(TAG,"who calls"); right? but this actually force closes my app without any Error Log or logcat info – Thiago Jul 17 '13 at 20:27

1 Answers1

0

I think you are going in the Right direction, if you are breaking into the code and hitting road blocks. The best resource to Study API's for Android is android developer site itself

http://developer.android.com/reference/android/widget/Adapter.html

PLus the [android] tagged questions on StackOverflow.

defau1t
  • 10,593
  • 2
  • 35
  • 47