Sample code problem?


#1

I downloaded the sample code for ch. 28, then commented out the code (the “if” statement in “onCreateOptionsMenu”) that implements SearchView for Honeycomb et al. However with this commented, things do not work so well:

Specifically, the onNewIntent method is never called, which means that the search is never executed.

Is something missing?


#2

Yep! That will happen on Honeycomb and later releases. This is because the menu is displaying a SearchView action view without hooking it up to anything.

To get it to work, either:

a- Restore the if statement you commented out.

or:

b- Remove the android:actionViewClass attribute from your search menu item.


#3

This book have caused me a lot of frustration. The momentum of learning is broken on the later chapters. What happened? It was good at first and the quality of text degraded as progresses. Not all concept are explained very well, I have to check StackOverflow/docs from time to time. Now I tried continuing on with this project found on Chapter 26. I just used 26th sample codes since I could no longer use the app I developed prior to that since I could not show the action bar.

Now following the book on chapter 27, everytime I press on search button. Nothing happens! I tried the sample code on 28 and it works fine. Is there something missing from the book?

Thanks.