2012

Snippets, Tutorial

Android EditText text changes Listener

If you want “listen” to the text changes from an EditText you have to use the TextWatcher. Bellow I will show you an example of TextWatcher: //first, we create an EditText EditText answer = new EditText(this); //second, we create the TextWatcher TextWatcher textWatcher = new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int […]

, ,
Tutorial

Detect when Done key is pressed

If you want to detect when a key from soft keyboard is pressed, like Done key, you can use the following code: mEditText = (EditText)findViewById(R.id.edit); mEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { //verifies what key is pressed, in our case verifies if the DONE key is pressed if (actionId

, ,
Solutions, Tutorial

Android SSL self signed certificate pass by

This is not my work, I have just found the solution some time ago on the internetUsing the class below you can pass by the ssl certificate error that Android may throw when you are trying to connect to a self signed certified server:First the EasySSLSocketFactory class : import java.io.IOException; import java.net.Socket; import java.net.UnknownHostException; import java.security.KeyManagementException; import

, ,
Solutions, Tutorial

Android SQLite Ignore Case from Database

If you want to select data from Database and you want to ignore the case of letters you should use COLLATE NOCASE in your query: “SELECT * FROM  myDataBaseName WHERE some_column= some_value COLLATE NOCASE” It’s not exactly an android issue but you might need some day in your android projects, so I hope it helps

, , ,
Solutions, Tutorial

Run Android Lint from command line

Not many of us use android Lint tool to scan the projects for possible performance or best practices tips. Eclipse has the Lint tool included into adt plugin so Eclipse users can take advantages of this. Ok but what about developers that use intellij IDEA or other IDE for android projects? The answer is simple,

, ,
Tutorial

Android PreferenceActivity & SharedPreferences tutorial

I will start with an example. Let’s assume that we want the user to change the date format of your application. For this you must have a class that extends PreferenceActivity, but first you have to create an XML file like this: 1. Make a directory in res called “xml” 2. In the xml directory

, , ,
Scroll to Top