Android RecyclerView notifyItemChanged() IllegalStateException “Cannot call this method while RecyclerView is computing a layout or scrolling”

If your Android app is crashing with error IllegalStateException “Cannot call this method while RecyclerView is computing a layout or scrolling”, you may try placing your notifyitemchanged inside a Runnable. Assuming you have a call to notifyItemChanged() inside onBindViewHolder() that is making your app crash with IllegalStateException, you may try something like this:

Read More

Android app development: click a ListView item programmatically

I’m going to share a code snippet that you may use to programmatically click a ListView item in your Android app. This will not simply highlight the desired ListView item, but also trigger the onItemClick listener. This code is what I placed in a Fragment’s onLoadFinished() method:

Simply replace the default_position value with the […]

Read More

Android app codes for Google Maps with clustering

I prepared Android app codes with Google Maps and clustering feature. Feel free to use these as basis for your new projects. They are on GitHub: [1] Default Map Markers: catzie/SimpleAndroidMapClustering   [2] Custom Map Markers: catzie/Simple-Android-Map-Clustering-with-Custom-Markers   I simply took the necessary classes and res files from Android Maps Utility demo, and then placed […]

Read More

Android Maps: Get current location coordinates with Google API Client Builder

To get your current location via Google Map in an Android app, this was how we do it:

Stop. Don’t use that! The method GoogleMap.getMyLocation() is deprecated. Instead, we need to use FusedLocationApi and the callback onLocationChanged(). Here’s an example code that works for me ( consider copying the contents of onResume() into onStart() […]

Read More