Android Development: How to Add an Auto Complete View

This tutorial shows you how to add a Country text field with an auto complete feature. Note, the default threshhold for autocomplete is 2, so you will need to enter two characters before autocomplete will recognize your input. You can download the below project.

1. AutoCompleteTextView is an implementation of the EditText widget that will provide auto-complete suggestions as the user types. The suggestions are extracted from a collection of strings.
2. Create a project
3. Open Main.xml and add an AutoCompleteTextView
4. Build project to update the R.java file
5. Add this code in OnCreate:

ArrayAdapter adapter = new ArrayAdapter(this,
android.R.layout.simple_dropdown_item_1line, COUNTRIES);
final AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView)

6. Add this code after OnCreate():

static final String[] COUNTRIES = new String[] {
"Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra",
"Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina",
"Armenia", "Aruba", "Australia", "Austria", "Azerbaijan",
"Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium",
"Belize", "Benin", "Bermuda", "Bhutan", "Bolivia",
"Bosnia and Herzegovina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory",
"British Virgin Islands", "Brunei", "Bulgaria", "Burkina Faso", "Burundi",
"Cote d'Ivoire", "Cambodia", "Cameroon", "Canada", "Cape Verde",
"Cayman Islands", "Central African Republic", "Chad", "Chile", "China",
"Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo",
"Cook Islands", "Costa Rica", "Croatia", "Cuba", "Cyprus", "Czech Republic",
"Democratic Republic of the Congo", "Denmark", "Djibouti", "Dominica", "Dominican Republic",
"East Timor", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea",
"Estonia", "Ethiopia", "Faeroe Islands", "Falkland Islands", "Fiji", "Finland",
"Former Yugoslav Republic of Macedonia", "France", "French Guiana", "French Polynesia",
"French Southern Territories", "Gabon", "Georgia", "Germany", "Ghana", "Gibraltar",
"Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guinea", "Guinea-Bissau",
"Guyana", "Haiti", "Heard Island and McDonald Islands", "Honduras", "Hong Kong", "Hungary",
"Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica",
"Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Kuwait", "Kyrgyzstan", "Laos",
"Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg",
"Macau", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands",
"Martinique", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia", "Moldova",
"Monaco", "Mongolia", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia",
"Nauru", "Nepal", "Netherlands", "Netherlands Antilles", "New Caledonia", "New Zealand",
"Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "North Korea", "Northern Marianas",
"Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru",
"Philippines", "Pitcairn Islands", "Poland", "Portugal", "Puerto Rico", "Qatar",
"Reunion", "Romania", "Russia", "Rwanda", "Sqo Tome and Principe", "Saint Helena",
"Saint Kitts and Nevis", "Saint Lucia", "Saint Pierre and Miquelon",
"Saint Vincent and the Grenadines", "Samoa", "San Marino", "Saudi Arabia", "Senegal",
"Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands",
"Somalia", "South Africa", "South Georgia and the South Sandwich Islands", "South Korea",
"Spain", "Sri Lanka", "Sudan", "Suriname", "Svalbard and Jan Mayen", "Swaziland", "Sweden",
"Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "The Bahamas",
"The Gambia", "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey",
"Turkmenistan", "Turks and Caicos Islands", "Tuvalu", "Virgin Islands", "Uganda",
"Ukraine", "United Arab Emirates", "United Kingdom",
"United States", "United States Minor Outlying Islands", "Uruguay", "Uzbekistan",
"Vanuatu", "Vatican City", "Venezuela", "Vietnam", "Wallis and Futuna", "Western Sahara",
"Yemen", "Yugoslavia", "Zambia", "Zimbabwe"

Android Development: How To Add An Image Button

This application shows you how to add an imagebutton to your Android form and display a message using the Toast widget. A toast is a view containing a small message for the user. The toast class helps you create and show those. You can download the project file.

1. Create a new project
2. Open Main.xml in res/layout

3. Add a ImageButton to layout file main.xml

4. Set the Background property to an image in your project

5. Note the value for the imageButton ID

6. In ButtonActivity.java add the following code to the OnCreate() method. Make sure that R.id.ImageButton01 matches your imageButton’s ID.

final ImageButton button = (ImageButton) findViewById(R.id.android_button);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// Perform action on clicks
Toast.makeText(HelloFormStuff.this, "Beep Bop", Toast.LENGTH_SHORT).show();

7. Run application and select the image, “Beep Boo” message appears: Screen shot


How to Debug an Android Application in Eclipse

1.Select the ApplicationManifest.xml document in the project tree

2.In the AndroidManifest.xml UI select the Application Tab

3.In the Application tab set the Debuggable value to true

4.Run your project in debug by right clicking the project folder and selecting

5.Select the Dalvik Debug Monitor Server (DDMS) in the upper right corner

6.You should see your application in the Devices tab with a green debug icon next to it

7.The Debug Perspective will launch

Android Development: How to use Screen Capture

1.Start Eclipse
2.Plug Android device into USB port
3.Select the Dalvik Debug Monitor Server (DDMS) in the upper right.

4.In the Devices tab select the Screen Capture Icon

5.A screen capture of your device will appear!


Dark Development: Visual Studio and Vim settings

This video shows you how to import environment settings into Visual Studio 2005/2008. I am using a dark setting based on vibrant ink that was created by John Lam. I find that this setting helps reduce eye strain and it makes code much easier to read. If you want to import the same settings here is the Download Link.



Installing and Uninstalling Services

1. Open a Visual Studio Command prompt and change directory to where your project's compiled executable file is located.
2. Run InstallUtil.exe from the command line with your project's output as a parameter:

> installutil yourproject.exe

To uninstall your service manually

1.Run InstallUtil.exe from the command line with your project's output as a parameter. Enter the following code on the command line:

> installutil /u yourproject.exe


Oracle xe Backup and Restore for Windows


To dump a single schema to disk use this command

- Open a command prompt and navigate to the server\bin folder and execute this command:

exp user/password FIlE=schemaname.dmp OWNER=schemaname


imp user/password FIlE=schemaname.dmp

Avoiding SQL Injection Attacks

Some good links on avoiding SQL injection attacks:

How to read from the app.config file

Create your config file in Project->Properties->Settings. This will generate your app.config file. Next build your app. In the bin directory look for .exe.config . Use this exe.config file to update your app once it is deployed. I built a service, installed the service, then copied the exe.config file into the same directory.

To access app.config from code use: Settings.Default.


Create Event Viewer Log with System.Diagnostics.EventLog

Here's some code that will log a message in an event viewer:

EventLog EventLog1 = new System.Diagnostics.EventLog();

if (!EventLog.SourceExists("Name"))
"Name", "Application");

EventLog1.Source = "Name";
EventLog1.WriteEntry(message.ToString(), EventLogEntryType.Error);


@@identity equivalent in oracle

@@identity equivalent in oracle
Oracle uses sequences to generate unique values for identity columns. You can access the current identity value and the next value in SQL via these pseudocolumns :
  • CURRVAL: Returns the current value of a sequence

  • NEXTVAL: Increments the sequence and returns the next value

CURRVAL and NEXTVAL have to associated with a sequence. For example myTable_seq.CURRVAL or myTable_seq.NEXTVAL.

Connect to Oracle XE server from Oracle.DataAccess.Client

Here is the connection string to connect to an Oracle XE server:

"Data Source=//SERVERNAME/XE;" +

Executing Multiple Inserts in Oracle

If you are inserting multiple inserts via a .net application you will need to format your inserts like so:

"begin insert into Task values(11,'tname');insert into
Task values(12,'tname');insert into Task values(13,'tname');insert into
Task values(14,'tname');end;";


Developing BlackBerry Applications in Visual Studio

To start developing BlackBerry applications in Visual Studio 2005 or 2008 you will need to download the BlackBerry plugin for Visual Studio. One important setting that will cause saving issues if you don't have it correctly set is "Save new projects when created", this needs to be checked (located in Tools->Options->Products and Solutions/General).


Using ActiveMQ to stage data

Are you developing a mobile application and the backend is not finished but you still need to test the app? Use the open source message broker tool ActiveMQ to stage data in a test harness and push data down to the device. You data can be stored in XML documents that a developer can trigger whenever they are ready to test.


How to get started with test-driven development

Test-driven development is focused on short development iterations

Here is the general process:
  1. Add a test - Developer must completely understand the software requirements
  2. Run all tests- Confirms test harness is functioning and the new test fails (New code has not been written yet)
  3. Write some code -This is meant to be the first pass and will likely improve as the tests are performed
  4. Run the automated tests
  5. Refactor code- Clean it up


Google AJAX Libraries API

Open source JavaScript libraries are great but maintaining a production copy has its drawbacks. Google takes all the hassle out of maintaining these libraries. Check out Google AJAX Libraries API at Google Code


Simple Ajax Example

Today we are having more fun with XMLHttpRequest. This video tutorial will show you how to call a server side script when the user adds text to web form's text box. The server side script returns the current date/time.

That's it, pretty simple. Here is the project file (ajaxExample.zip): Download Project File


Where did XMLHttpRequest come from?

XMLHttpRequest is a key part of Ajax. The other part is javascript, so XMLHttpRequest is basically half of Ajax.

You can use it to get info from the server:
function handler() {
if(this.readyState == 4 && this.status == 200) {
// so far so good
if(this.responseXML != null && this.responseXML.getElementById('test').firstChild.data)
// success!
} else if (this.readyState == 4 && this.status != 200) {
// fetched the wrong page or network error...

Go Daddy $7.49 .com sale 200x200

var client = new XMLHttpRequest();
client.onreadystatechange = handler;
client.open("GET", "test.xml");
You can log a message from the server:
function log(message) {
var client = new XMLHttpRequest();
client.open("POST", "/log");
client.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
Also, you can check the status of a document on the server:

function fetchStatus(address) {
var client = new XMLHttpRequest();
client.onreadystatechange = function() {
// in case of network errors this might not give reliable results
if(this.readyState == 4)
client.open("HEAD", address);

Find Your Special Someone

Where did XMLHttpRequest come from?

Microsoft gave us XMLHttpRequest in 2000, it was originally a server side API call for Outlook Web Access. Over time, web browsers have implemented XMLHttpRequest. If you are using a modern browser (IE 7 and up) then your page's javascript can use XMLHttpRequest. If you are sticking to your guns and not upgrading your browser then your page needs to invoke. XMLHttpRequest via an ActiveX Object.

In order to stomp out platform-specific code, the World Wide Web Consortium developed a working draft of XMLHttpRequest object's API.