Pluralization in Android

If you are writing an app, that uses a string containing numbers, for example: Deleted 1 message Deleted 2 messages You could manually create two different strings, and show either one by using an if/else, depending on the number variable. However, as you start internationalizing your app, by adding more translations, this quickly gets out of hand! Using Plurals Luckily, theres a great solution for this. In Android, you can use something called "plurals". You can use plurals in

» Read more

Creating a nice looking List dialog with images and text

This tutorial, will demonstrate how you can create a great looking selectiondialog, containing both text and images. This list can then be used either directly in an Activity, Fragment, or as an Activity looking like a dialog. In this example, I will go with the latter, and create an activity that looks like a selection dialog window, that, in this case will be used to choose a country. Creating such a selection list is easy if it should contain text

» Read more

How to extract strings into strings.xml resource files in Android Studio

I have previously posted a guide on how to extract string resources in Eclipse, so I thought I would do it for Android Studio too, as it is not directly obvious how to acheive this. All your applications strings should be placed in the various /values/strings.xml files in your app. This is the best practice, gathers all texts, and easily enables you to translate your app into other languages. While developing apps, it might be easier to just

» Read more

How to easily extract strings from your Android code into the strings.xml file

This handy little feature can save a lot of time and manual work when working with Android apps. If you during Android development in Eclipse use hardcoded strings in your java code, like in the example below: package test.layout; import android.app.Activity; import android.os.Bundle; import android.widget.Button; public class LayoutTest extends Activity { private Button btn; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); btn = (Button) findViewById(R.id.Button01); btn.

» Read more