Posts Tagged: SDK


7
Jun 11

A Generic ListView and Spinner Adapter for Java Collections

In this post I will introduce a library which you can use to display elements from any java.util.Collection (e.g. LinkedList, ArrayList, HashSet, Queue, Stack, TreeSet,…) within a ListView or a Spinner. It’s even possible to use this library to implement any layout you want for your entries (e.g. a multi-line entry, an entry with including an image, etc…).

So this library is a very generic approach to display various data sets with custom layouts in a Spinner or a ListView. Continue reading →


13
Apr 11

Using Android Activities and Services in multiple Projects

When developing Apps for the Android OS you might end up in the situation where you have common Activities or Services which could be reused in multiple Apps with just a little modification. As you don’t want to copy these classes into every single project – which would lead to a hardly maintainable code – you would seek a way to reference the source of these classes from multiple projects. For non-android applications an approach for this problem would be to break up the code into multiple libraries so that the required functionality can be referenced from multiple projects. As long as you are not interacting with external resources this attempt is also possible in Android projects (build a jar and reference it from the projects). But if you are using external resources these classes can’t be used within a library. This is caused by the fact that the Android SDK won’t generate matching ids within the “R” class for external resources which are included in a referenced jar file. In this post I want to show you different solutions for this problem which can avoid the necessity to copy the source code into the projects. Continue reading →


18
Mar 11

Using custom layouts for “Spinner” or “ListView” entries in Android

Today we are going to take a look at custom entries for a Spinner or ListView. Android allows the developers to create custom layouts for the entries in a Spinner or ListView. Using this mechanism it’s possible to implement highly customized designs for the default GUI elements such as the spinner. For example it’s possible to implement a spinner with entries consisting of an image and of multiple lines of text. In this post I will explain the three steps required to implement this functionality using the Query Contacts App from my previous post. In this App I’ve implemented a Spinner with custom entries to display the contact photo together with the contact name embedded in a single entry. Furthermore each element of the ListView which is used to display the details of the contact contains two lines of text. Continue reading →


14
Mar 11

Working with the “ContactsContract” to query contacts in Android

When I was looking at the official example on the Google Android Developers site for accessing content providers in Android (http://developer.android.com/guide/topics/providers/content-providers.html) I found an outdated example to query contacts which is using deprecated fields in the Android API. As I’ve seen quite some developers who are still relying on that deprecated example to implement their functionality even when using the newer API levels I’ve decided to post an example which is using the new way suggested in the Android API.

Query Contacts AppTo demonstrate the features of the new API the example App is querying all available contacts on the phone and additionally commonly used information from the contacts content provider such as the name, phone numbers, email addresses and of course the photo. Continue reading →