How to detect changes to your Android Preferences

This will demonstrate how to listen for changes to the user preferences in your app, so  that you can perform tasks depending on what the user selected/changed on the preferences screen. I have an app, with a listfragment displaying rows of text. There is also a preferences screen (SettingsActivity.java) where users can set the sorting order of the list. When users change the sort order, the list should be refreshed, to disaply the items in the new order.

» Read more

How to cut off too long lines of text in Lists with ellipsize

If you are using lists in your app, and some of the list items have too long text, making it wrap to several lines like item number three in the following image, then this trick will show you how to create better looking lists. Before, Text wrapping to two lines: Your custom list item xml layout file may look like this: <?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android"

» Read more