Tag: help

“Design and document for inheritance or else prohibit it”

The title is the name of Item 17 from the second edition of Joshua Bloch’s Effective Java. I did not see the importance of this advice – or should we call it rule – until I ran into an issue during Android development that was caused by violations of this rule in the Android Framework.

Read more →

View.setEnabled versus android:enabled

This post will be about an interesting observation I made when working on a custom View that did not extend EditText, but contained one.

Read more →

Dangers of multi-catch in Android

One of the new features introduced in Java 7 was the possibility to handle multiple exception types in a single catch block.

Starting with March 2014 (added in SDK Tools 22.6), this feature can be used for Android applications too when targeting Android Froyo or later.

However, in Android, there is a special case where multi-catch can bring trouble for the developers.

Read more →

Reference resources caRefully

I knew that I would write a post about this phenomenon as soon as I met it.

Here is the story: during my work, I was assigned to fix a bug. The bug was the following: when navigating to a certain screen, the application crashed with ClassCastException saying that I cannot cast Linearlayout to FrameLayout.

I checked the layout file that was inflated, and the root element was indeed FrameLayout, making the error seem impossible. But then… what was wrong?

Read more →

Styling composite Views in Android – Part 2

This is the second part of the blog post I wrote to help facing the problems that could arise when styling complex, composite Views. Now it is time to go further, and see a working solution!

Read more →

Styling composite Views in Android – Part 1

Android provides two very useful features: styles and themes. Styles save you from repeating yourself in your XML layouts over and over again, while themes make it easy to adjust the look of your application without having to modify a lot of code.

Read more →