Android SearchView tutorial: EditText with phone contacts search and autosuggestion (including source code)

SearchView is available in Android 3.0+. It enables you to search for any data by means of ContentProvider. You can write your custom ContentProvider or use the existing one. For simplicity I will show how to use Android ContactsProvider. The Goal The goal is to buil SearchView to find contact from address book with auto … Continue reading Android SearchView tutorial: EditText with phone contacts search and autosuggestion (including source code)

Source code: Android custom ListView

Since many of you have asked for a source code of this tutorial: Android custom ListView tutorial I decided to write it and share. The tutorial was witten based on a bigger project, so I could not share it. This is why I have written custom ListView source code example from scratch based on the … Continue reading Source code: Android custom ListView

Android: change desktop wallpaper programatically

Here is an instruction how to change desktop background on android device rogramatically by means of WallpaperManager. For simplicity the new wallpaper is taken from project resources. private void setDesktopWallpaper() { try { WallpaperManager wallpaperManager = WallpaperManager.getInstance(this); wallpaperManager.setResource(R.drawable.my_wallpaper); } catch (IOException e) { SLog.e(TAG, "Error changing wallpaper: " + e.getMessage()); } } To use another … Continue reading Android: change desktop wallpaper programatically

Android: play default notification sound

When aplication wants to notify user with sound, the best way to do it is to play notification sound that is set by the user on his device. To do it, first you need to get Uri to that audio file from RingtoneManager. After that create a Ringtone object from that Uri and play it: … Continue reading Android: play default notification sound

Android: complete widget tutorial (including source code)

Tutorial will show how to build android widget with one button and image. Button press will change the image displayed. The result will look as follows Source code Hereby I share my widget on github. Feel free to download. 1. Create widget layout layout is defined as any other layout in Android app. My layout consists … Continue reading Android: complete widget tutorial (including source code)

Android custom button layout tutorial

The goal of this tutorial is to create customized button with your own background. The result will be something like that: There are two ways of creating such background. The common one is to define it in XML file - this way I will describe here. The other, more elastic way is to define it … Continue reading Android custom button layout tutorial

Android custom ListView tutorial (including source code)

This tutorial will show how to prepare ListView with custom items and buttons (with click handlers) like this: Source Code The source code for this tutorial is in this post. You can download it and use as You like. 1. Create single list item layout Item consists of three views: name, value (EtitTexts) and delete … Continue reading Android custom ListView tutorial (including source code)

Android dp and px: what is it about

What is it While programing GUI on Android one should mostly define dimensions in dp (density independent pixels) instead of px (pixels). The main difference between both is: dp will always have the same size on every smartphone screen. px is not always the same dimensions. It is well visualized on screenshots on Android API Guides, in section Density … Continue reading Android dp and px: what is it about