I bet you used the filter() function to do it, right?

This function only works if you specify one field or an array of fields to use in filtering out results based on 1 search text. If there is more than 1 value to consider in filtering entries in the store, you will have to use the filterBy() function for custom and complex scenarios.

Check out this sample code.

The code filters entries in the store where a model’s field name labeled fieldname1 and fieldname2 has a substring of searchkey1 and searchkey2 respectively. That is how you should do it.

This won’t work.

This was a pain to find out. While my Android widget was working okay considering that I only set it to have only 1 size, it took me a very long time to find out that the same PendingIntent object is used by the Android system when certain attributes are created the same way e.g. class, action, request code.

The quickest and easiest solution is to use the appWidgetId as the value of the request code in the PendingIntent parameter when you either call the getActivity(), getBroadcast() or getService() methods.

That should make it unique in such a way that the PendingIntent object will be used only for that certain widget no matter which size or which instance it is.

Other options would be to give different values for its setData() and setAction() methods like adding a System.currentTimeMillis() but sometimes we may want our action value to be fixed so the best option in my opinion is to focus on the request code value having a unique value.

That should give make your multiple widget instances work.

While currently working on a new app, I decided to use a PagedView with 3 screens. I was surprised that the 3rd screen will always show what is displayed in the first screen. I tested to see what would happen if I use 4 screens. The same thing happened: the 4th screen displayed the contents of the 2nd screen.

I was confused why it acted like this. Instantiating new views on the 3rd and 4th position will work. However, I wanted to find a way where the views had to be reused rather than creating new instances because more memory will be used.

I asked Cyril, the creator of Greendroid if this is a bug or not. This is his answer.

The PagedView is based on a reuse mechanism really similar to the one used by ListView. As a result, once a new page is required, the PagedView asks the PagedAdapter a new page trying to reuse a old page (that is a page that is no longer visible on screen).
This is the reason why you have at most 2 pages instantiated : you have to reuse the previously created pages.
If your pages are really different, you can by-pass this behavior by not reusing the convertView. Just keep in mind having a very small number of pages as it will probably imply having a large number of pages in memory at the same time (hence a large number of Views).

I guess having multiple paged views at 3 screens is enough. Going beyond that is probably overkill. If you can make it up to 2 screens only, then the better.

Related Posts Plugin for WordPress, Blogger...