tutorial

Mojito builder

SDK Version: 
M3

Last week, in spite of the winter the weather was very mild. The beams of the winter sun brought forward the memories of the summer: hot weather, girls in bikinis, mojitos! We have already gotten a promise for the first two in a certain form here in Helloandroid HQ (the heating system will be repaired, and we 'll have some women colleagues), but it is our task to make coctails.

  1. public class Mojito {
  2.         private final int mWhiteRum;    //cl
  3.         private final int mBrownSugar;  //spoun
  4.         private final int mLime;                //clove
  5.         private final int mMenta;               //piece
  6.         private final int mSoda;                //decilitre
  7.                
  8.         public Mojito(int whiteRum, int brownSugar, int lime, int menta, int soda){
  9.                 mWhiteRum = whiteRum;
  10.                 mBrownSugar = brownSugar;
  11.                 mLime = lime;
  12.                 mMenta = menta;
  13.                 mSoda = soda;
  14.         }
  15. }

Quick guide to quick autocomplete textview

SDK Version: 
M3

This demo shows how to speed up the original autocomplete textview assuming that we can work with ordered data.

Let's prepare a simple test environment, which demostrate the difference between the two versions. Then let's generate a few thousand test data, and create two textviews from which we will speed up the second one.

  1. public class Main extends Activity {
  2.         AutoCompleteTextView mAutoCompleteTextViewOriginal;
  3.         AutoCompleteTextView mAutoCompleteTextViewQuick;
  4.  
  5.         @Override
  6.         public void onCreate(Bundle savedInstanceState) {
  7.                 super.onCreate(savedInstanceState);
  8.                 setContentView(R.layout.main);
  9.                
  10.                 String[] values =  createLongSortedStringArray(4);
  11.        
  12.                 mAutoCompleteTextViewOriginal = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextViewOriginal);
  13.                 ArrayAdapter<String> originalAdapter = new ArrayAdapter<String>(this, R.layout.autocomplete_listitem, values);
  14.                 mAutoCompleteTextViewOriginal.setAdapter(originalAdapter);

Advanced exception handling in Android

SDK Version: 
M3

errorIn this tutorial I'll present you a simple exception handler class for Android. The class can invoke and display exceptions and it can be upgraded very easy for your further needs.

Is this the first run?

SDK Version: 
M3

Ever wanted to have a different flow of actions on the second or third run of your app? I had that many times, in almost every project that I haver worked on. So here is a little snippet, that you can use to store, and check the fact, if this is the first run of your app. You can modify it easily, to suit your needs.

How to display a custom dialog in your Android application

SDK Version: 
M3

How to display a custom dialog in your Android application

Yesterday Jozsi showed you, how to make an alert dialog, today I'm going to show you, how to make a custom dialog/popup window.
Sometimes, it's better to make your own dialog, because this way, you can display whatewer you want., the way you want it.
First, make your own layout, with the needed elements. Here, I'm going to use two buttons, a textview inside a scrollview, and an imageview...

Data Storage tutorial, basic samples are included

SDK Version: 
M3

    Data Storage Methods

  • Preferences
  • Preferences is a lightweight mechanism to store and retrieve key-value pairs of primitive data types.
     
  • Files
  • You can store your data in files on your mobile phone, or in a removable storage medium.
     
  • Databases
  • Android Api supports SQLite databases. All databases, SQLite and others, are stored on the device in /data/data/package_name/databases.
     
  • Network
  • You can also use the Internet to store and receive data, whether it's an SQLite database, or just a simple textfile.

Syndicate content