13,196,126 members (51,993 online)
alternative version

#### Stats

534.3K views
232 bookmarked
Posted 26 Aug 2010

# Introduction to Android development : TouchCalculator

, 13 Sep 2010
 Rate this:
Android tutorial with sample styled calculator implementation

## Introduction

I have been designing and developing mobile applications for less than 1 year, though I'm a professional software developer for 10 years or so, and this new mobile era makes me feel excited. As of today there are two and a half major platforms gaining pretty well reputation by the mobile users. Two of them are iOS (formerly known as iPhone OS) and Android and the half is long debated Windows Phone 7.

In this tutorial article I will try to introduce you to the general development principles of Android by building a real calculator application (TouchCalculator). By the end of this tutorial you will be able to build Android applications with simple user interfaces and backing business logic.

## Organization of the article

1. Visualize (sketch or mock up) your app (beginner)
2. Write down what your application will do (beginner)
3. Code a first shot UI which is basic and mimics your mock up (beginner)
4. Design your data structures (Minimum Java experience needed but not a must)
5. Improve the UI to make it match to your initial mock up (Android specific beginner level code)
6. Implement the business logic (Java experience required, but you do not have to understand all of the code, just realize that you have to think separately about your business logic)

## Preparing Yourself and The Development Environment

Before you get started, if you are totally new to Android I would suggest you to read the What is Android? section from the Android Developers site and I would also suggest you to have a look at Android Developers Blog.

## TouchCalculator MockUp

TouchCalculator, our sample and simple calculator, is a standard calculator supporting four arithmetic operations and three mathematical functions (namely square root, reciprocal and percentage) along with a memory buffer.

Let's start with the mock up of our calculator. Below is a color coded sketch of our application. I've separated the UI into logical parts and each part is represented with a color highlight. There is a reasoning behind the conceptual separation and this will be evident in the next sections of the tutorial.

So, let us see what is intended with each region in our mock up.

1. We will display the subsequent user input until user presses (=) to calculate the result or C to clear the input buffer
2. Immediate user input and the result of the buffer will be displayed
3. Memory buffer value will be displayed in this area
4. Memory buffer operation buttons
5. Other operation buttons
6. Calculate button
7. Arithmetic operation buttons
9. Immediate input and buffer clear buttons

## TouchCalculator Use Cases

Our calculator shall be able to support the following use cases

• Calculator shall be initialized with input value of 0 and as soon as the user starts pressing numeric keypad buttons, input capture shall start
• User will press the numeric keypad buttons and we will append each numeric value to the current value of Area #2
• If user presses the decimal separator button placed in Area #5 we shall append the separator to the current value of Area #2
• When user presses an arithmetic operator button placed in Area #7 we shall display the input buffer content in Area #1. If input buffer has enough input to produce a result we shall also calculate the result and display the value in Area #2
• When user presses (=) button and if input buffer has enough input to produce a result we shall calculate the result and display it in Area #2, else do nothing.
• When user presses the backspace button (<-) we shall trim the last digit of the value displayed in Area #2
• When the user presses the CE button we shall reset the value displayed in Area #2 so that it becomes 0
• When user presses the C button we shall reset the input buffer and the value displayed in Area #2 so that it becomes 0
• When user presses (±) we shall toggle the sign of the user input value displayed in Area #2
• When user presses MC button we shall clear the memory buffer
• When user presses MR button we shall read the value in memory buffer and display that value in Area #2
• When user presses MS button we shall set the value of the memory buffer to the value displayed in Area #2
• When user presses M+ or M- buttons we shall add/subtract the value displayed in Area #2 with the existing value of the memory buffer
• When user presses SQRT button we shall calculate the square root of the value displayed in Area #2 and display the result in Area #2
• When user presses 1/x button we shall calculate the reciprocal of the value displayed in Area #2 and display the result in Area #
• When user presses % button we shall calculate the result of the input buffer and find the percent of the result and display in Area #2

## Creating The Bare Bones User Interface

Since we have our calculator mock up, we can start creating the bare bones Android user interface of our calculator. When you create a new Android project in Eclipse, you will have a default layout xml file named main.xml under res/layout folder. We will create the bare bones calculator user interface declaratively, not from code, inside this xml file. Using declarative xml files, layout files, while constructing the user interface has advantages. The primary advantage of using XML is that you separate the presentation of your application from the code used to control your applications behavior. In a team environment this separation enables designers and coders to work on the same application simultaneously. Designers familiar with HTML can easly design Android user interfaces once they get familiar with Android layout vocabulary.You can read more about Android layouts from here.

Now, lets see how we can accomplish an Android UI to represent different UI parts sketched in our TouchCalculator Mockup. Building blocks of Android UI are Views and ViewGroups. Views are basic user interface bits which provide screen layout and user interaction. For example Button, TextView and CheckBox are simple views extending the abstract View class. ViewGroups are composite user interface bits which can contain multiple Views and other ViewGroups. LinearLayout and GridView are two of the view groups we will use to construct our calculator.

In our mock up, we have actually four sections laid out in linear direction vertically. First three sections are for the areas labeled with 1,2 and 3 and the fourth section is for the keypad, containing sections labeled with 4,5,6,7,8 and 9. Thus, we will use LinearLayout ViewGroup so that we can place Views for each section. Here is our bare bones layout XML

```<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent">

<TextView

android:id="@+id/txtStack"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:textSize="15sp"

android:gravity="right"

android:layout_marginTop = "3sp"

android:layout_marginLeft = "5sp"

android:layout_marginRight = "5sp"/>

<TextView

android:id="@+id/txtInput"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:textSize="25sp"

android:gravity="right"

android:layout_marginLeft = "5sp"

android:layout_marginRight = "5sp"/>

<TextView

android:id="@+id/txtMemory"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:textSize="15sp"

android:gravity="left"

android:layout_marginLeft = "5sp"

android:layout_marginRight = "5sp"/>

<GridView xmlns:android="http://schemas.android.com/apk/res/android"

android:id="@+id/grdButtons"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:columnWidth="90dp"

android:numColumns="5"

android:verticalSpacing="10dp"

android:horizontalSpacing="10dp"

android:stretchMode="columnWidth"

android:gravity="center"/>
</LinearLayout>```

We will use TextView to represent areas labeled with 1,2 and 3 in our mock up. We will use GridView ViewGroup for the keypad. We will place our keypad buttons inside the cells of the GridView at run time by using an Adapter.

Most of the View and ViewGroup attributes are self explanatory. You can infer easily what an attribute is used for, actually Eclipse xml editor will also help you if you press Ctrl+Space you will be presented a list of attributes. I will mention id attribute explicitly since it has special importance. Any view or view group can have an id attribute, but this is not a must. If you want to get reference to the View or ViewGroup from your code, you should set the id attribute of your Views and ViewGroups. id attribute has some sort of special notation which you can read more about here.

If you press on the Layout tab in Eclipse  XML editor where our layout is defined, you will see the bare bones UI as shown in the image below. Note that by using the LinearLayout we have managed to put each logical section in linear direction vertically.

The XML layout we have defined is not enough by itself, since the users can not get into interaction with our application through the layout directly. As the terminology implies layout XML is used just for defining the placement and visual aspects of the UI bits. What we need in order to enable user interaction is the Activity class, which controls the behavior of our UI and enables user interaction.

When you create a new Android project with Eclipse, you will be asked for the details of your project and one of them is the optional Create Activity check box along with a name for your first Android activity class. For all practical purposes we have named our activity to be main. Eclipse will automatically create a "main.java" file under the src/package node. Here is the initial contents of our main activity class

```package com.pragmatouch.calculator;

import android.app.Activity;
import android.os.Bundle;

public class main extends Activity {

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

}
}```

As you can see, we override the onCreate (Line 10) method of the base Activity and perform activity initialization, loading layout is part of our initialization process, inside the overriden method.

setContentView method called on Line 12 belongs to base Activity class and is used to load the UI layout from a resource (main.xml) identified by an integer. Please note how we get the integer identifier of our main.xml. When Android builds your application, it automatically generates a class named R (can be found under /TouchCalculator/gen/com/pragmatouch/calculator/R.java) and generates identifier constants for your resources, since main.xml is a resource Android generates a constant for us and we can use that constant from our code to load our layout.

If you run the application you will see an empty UI with two linear TextViews placed on top with no keypad.

In this section, we will model our keypad buttons using Java enum type. Java enums are interesting for a guy like me. Spending too many years with C# I must confess that Java enums are much more capable than the C# enums since the Java enum class body can include methods and other fields.

To model the keypad buttons we will declare a KeypadButton enum class, which will also hold button text and category information.

```package com.pragmatouch.calculator;

CharSequence mText; // Display Text

mText = text;
mCategory = category;
}

public CharSequence getText() {
return mText;
}
}```

Each keypad button shown in our mockup is represented with an enum constant and each constant also holds a text and a category value. We also use Java enums to represent the keypad button categories and declare a KeypadButtonCategory enum class.

```package com.pragmatouch.calculator;

MEMORYBUFFER
, NUMBER
, OPERATOR
, DUMMY
, CLEAR
, RESULT
, OTHER
}```

We will utilize KeypadButtonCategory enums for applying different styles for each category so that our sample calculator seems more colorfull.

As I mentioned in the previous sections, we will use GridView to display our keypad. We will use a five column GridView and we will declare an Adapterwhich extends the BaseAdapter class and is responsible of providing data to our AdapterView that is a GridView in our case.

```package com.pragmatouch.calculator;

import android.widget.*;
import android.content.*;
import android.view.*;
import android.view.View.OnClickListener;

private Context mContext;

mContext = c;
}

public int getCount() {
return mButtons.length;
}

public Object getItem(int position) {
return mButtons[position];
}

public long getItemId(int position) {
return 0;
}

// create a new ButtonView for each item referenced by the Adapter
public View getView(int position, View convertView, ViewGroup parent) {
Button btn;
if (convertView == null) { // if it's not recycled, initialize some attributes
btn = new Button(mContext);

// Set CalculatorButton enumeration as tag of the button so that we
// will use this information from our main view to identify what to do
}
else {
btn = (Button) convertView;
}

btn.setText(mButtons[position].getText());
return btn;
}

// Create and populate keypad buttons array with CalculatorButton values
}```

Adapters are responsible for providing data to AdapterViews, in our case the data we will provide to our GridView is keypad button instances. To be able to create these button instances, we define an array of KeypadButton enums on Line 47-52.

Our KeypadAdapter provides keypad button instances to our GridView with the getView (Line 28-44) method implementation where we instantiate or revoke our keypad buttons and set their properties based on their position on the GridView.

Please note what Line 36 does in the code. We set KeypadButton enumeration instance  as the tag of our Button and we will use that tag value during business logic implementation to identify what to do when the user presses a keypad button.

Now, we have defined our Adapter and it is time to wire-up the GridView with our KeypadAdapter. Here is our main.java file.

```package com.pragmatouch.calculator;

import android.app.Activity;
import android.os.Bundle;
import android.widget.GridView;
import android.view.View;
import android.view.View.OnClickListener;

public class main extends Activity {

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

// Get reference to the keypad button GridView

});

public void onItemClick(AdapterView<?> parent, View v,int position, long id) {
// This will not help us catch button clicks!
}
});

}

}```

Note that we create an instance of our KeypadAdapter on Line 25 and set this instance as the adapter of our GridView on Line 28. Another thing I want you to notice in the code above is the findViewById call on Line 21. As I noted in previous section, we use the value of the id attribute we have assigned to our GridView in our layout XML (main.xml).

When you run the TouchCalculator at this point, you will see the following UI which is almost the same as our mock up.

Now it is time to implement the business logic of our calculator. We will utilize Java Stack class in order to implement our calculation logic. We will have two Stack instances; the first instance will hold the user input and the second stack will hold the intermediate calculation results. We will wrap our business logic as an instance method inside our main class. Here is our ProcessKeypadInput method along with some utility methods.

```private void ProcessKeypadInput(KeypadButton keypadButton) {
// Toast.LENGTH_SHORT).show();
String currentInput = userInputText.getText().toString();

int currentInputLen = currentInput.length();
String evalResult = null;
double userInputValue = Double.NaN;

case BACKSPACE: // Handle backspace
// If has operand skip backspace
if (resetInput)
return;

int endIndex = currentInputLen - 1;

// There is one character at input so reset input to 0
if (endIndex < 1) {
userInputText.setText("0");
}
// Trim last character of the input text
else {
userInputText.setText(currentInput.subSequence(0, endIndex));
}
break;
case SIGN: // Handle -/+ sign
// input has text and is different than initial value 0
if (currentInputLen > 0 && currentInput != "0") {
// Already has (-) sign. Remove that sign
if (currentInput.charAt(0) == '-') {
userInputText.setText(currentInput.subSequence(1,
currentInputLen));
}
// Prepend (-) sign
else {
userInputText.setText("-" + currentInput.toString());
}
}
break;
case CE: // Handle clear input
userInputText.setText("0");
break;
case C: // Handle clear input and stack
userInputText.setText("0");
clearStacks();
break;
case DECIMAL_SEP: // Handle decimal seperator
if (hasFinalResult || resetInput) {
userInputText.setText("0" + mDecimalSeperator);
hasFinalResult = false;
resetInput = false;
} else if (currentInput.contains("."))
return;
else
userInputText.append(mDecimalSeperator);
break;
case DIV:
case PLUS:
case MINUS:
case MULTIPLY:
if (resetInput) {
mInputStack.pop();
mOperationStack.pop();
} else {
if (currentInput.charAt(0) == '-') {
} else {
}
}

dumpInputStack();
evalResult = evaluateResult(false);
if (evalResult != null)
userInputText.setText(evalResult);

resetInput = true;
break;
case CALCULATE:
if (mOperationStack.size() == 0)
break;

evalResult = evaluateResult(true);
if (evalResult != null) {
clearStacks();
userInputText.setText(evalResult);
resetInput = false;
hasFinalResult = true;
}
break;
userInputValue = tryParseUserInput();
if (Double.isNaN(userInputValue))
return;
if (Double.isNaN(memoryValue))
memoryValue = 0;
memoryValue += userInputValue;
displayMemoryStat();

hasFinalResult = true;

break;
case M_REMOVE: // Subtract user input value to memory buffer
userInputValue = tryParseUserInput();
if (Double.isNaN(userInputValue))
return;
if (Double.isNaN(memoryValue))
memoryValue = 0;
memoryValue -= userInputValue;
displayMemoryStat();
hasFinalResult = true;
break;
case MC: // Reset memory buffer to 0
memoryValue = Double.NaN;
displayMemoryStat();
break;
case MR: // Read memoryBuffer value
if (Double.isNaN(memoryValue))
return;
userInputText.setText(doubleToString(memoryValue));
displayMemoryStat();
break;
case MS: // Set memoryBuffer value to user input
userInputValue = tryParseUserInput();
if (Double.isNaN(userInputValue))
return;
memoryValue = userInputValue;
displayMemoryStat();
hasFinalResult = true;
break;
default:
if (Character.isDigit(text.charAt(0))) {
if (currentInput.equals("0") || resetInput || hasFinalResult) {
userInputText.setText(text);
resetInput = false;
hasFinalResult = false;
} else {
userInputText.append(text);
resetInput = false;
}

}
break;

}

}

private void clearStacks() {
mInputStack.clear();
mOperationStack.clear();
mStackText.setText("");
}

private void dumpInputStack() {
Iterator<String> it = mInputStack.iterator();
StringBuilder sb = new StringBuilder();

while (it.hasNext()) {
CharSequence iValue = it.next();
sb.append(iValue);

}

mStackText.setText(sb.toString());
}

private String evaluateResult(boolean requestedByUser) {
if ((!requestedByUser && mOperationStack.size() != 4)
|| (requestedByUser && mOperationStack.size() != 3))
return null;

String left = mOperationStack.get(0);
String operator = mOperationStack.get(1);
String right = mOperationStack.get(2);
String tmp = null;
if (!requestedByUser)
tmp = mOperationStack.get(3);

double leftVal = Double.parseDouble(left.toString());
double rightVal = Double.parseDouble(right.toString());
double result = Double.NaN;

result = leftVal / rightVal;
result = leftVal * rightVal;

result = leftVal + rightVal;
result = leftVal - rightVal;

}

String resultStr = doubleToString(result);
if (resultStr == null)
return null;

mOperationStack.clear();
if (!requestedByUser) {
}

return resultStr;
}

private String doubleToString(double value) {
if (Double.isNaN(value))
return null;

long longVal = (long) value;
if (longVal == value)
return Long.toString(longVal);
else
return Double.toString(value);

}

private double tryParseUserInput() {
String inputStr = userInputText.getText().toString();
double result = Double.NaN;
try {
result = Double.parseDouble(inputStr);

} catch (NumberFormatException nfe) {}
return result;

}

private void displayMemoryStat() {
if (Double.isNaN(memoryValue)) {
memoryStatText.setText("");
} else {
memoryStatText.setText("M = " + doubleToString(memoryValue));
}
}```

ProcessKeypadInput method is called each time user presses a keypad button and we decide what to do with a swtich/case code block. We also have some helper methods

• clearStacks, is used to clear our stacks and the user input TextView
• dumpInputStack, is used to dump the input stack as a single line string to the TextView represented as Area #1 in our mockup
• evaluateResult, is called when user presses an artihmetic operation keypad button or the (=) keypad button. Inside this method we try to calculate a result by popping values from our operation stack and we push the result as the first item to the operation stack if we were able to calculate a result
• doubleToString, utility method which is used to convert a double value to String
• tryParseUserInput, utility method where we try to parse the user input, represented as Area #2 in our mockup, as a valid double value
• displayMemoryStat, utility method used to dump the memory buffer status and value to the Area #3 in our mockup

## The Right Place To Call ProcessKeypadInput Method

In "Displaying The Keypad" section please take a look at the comment placed on Line 34. If you read the GridView Sample  in Android Developers site, you might think that this line is the right place to put the ProcessKeypadInput method call since the user will click on the keypad buttons which are in turn items of our GridView that in turn will trigger the OnItemClick event. This assumption is absolutely wrong in our case. If you put  the call to ProcessKeypadInput method  on that line and run your application OnItemClick of our GridView will not be fired even though a button is pressed. The reason for this misconception is this : Since Button views placed in the cells of the GridView are clickable, when user clicks over a button the Button view handles that click and the action is not propagated to the GridView.

Solution to this problem is pretty straight forward; we have to set OnClickListener of our keypad Button views and we will do that in our KeypadAdapter class. Below is the modified version of our  KeypadAdapter class.

```package com.pragmatouch.calculator;

import android.widget.*;
import android.content.*;
import android.view.*;
import android.view.View.OnClickListener;

private Context mContext;

// Declare button click listener variable
private OnClickListener mOnButtonClick;

mContext = c;
}

// Method to set button click listener variable
public void setOnButtonClickListener(OnClickListener listener) {
mOnButtonClick = listener;
}

public int getCount() {
return mButtons.length;
}

public Object getItem(int position) {
return mButtons[position];
}

public long getItemId(int position) {
return 0;
}

// create a new ButtonView for each item referenced by the Adapter
public View getView(int position, View convertView, ViewGroup parent) {
Button btn;
if (convertView == null) { // if it's not recycled, initialize some
// attributes

btn = new Button(mContext);
btn.setOnClickListener(mOnButtonClick);

// Set CalculatorButton enumeration as tag of the button so that we
// will use this information from our main view to identify what to
// do
} else {
btn = (Button) convertView;
}

btn.setText(mButtons[position].getText());
return btn;
}

// Create and populate keypad buttons array with CalculatorButton enum
// values

}```

We declared mOnButtonClick field on Line 12 and defined a setter method for this field on Line 19-21. Then we set OnClickListener of our Button views to mOnButtonClick value on Line 43-44.

In order to catch button clicks and call ProcessKeypadInput, we also have to modify our main class.

```package com.pragmatouch.calculator;

import android.app.Activity;
import android.os.Bundle;
import android.widget.GridView;
import android.view.View;
import android.view.View.OnClickListener;

public class main extends Activity {

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

// Get reference to the keypad button GridView

@Override
public void onClick(View v) {
Button btn = (Button) v;
// Get the KeypadButton value which is used to identify the
// keypad button from the Button's tag

}});
});

public void onItemClick(AdapterView<?> parent, View v,int position, long id) {
// This will not help us catch button clicks!
}
});

}

}```

## Are we done yet?

We have a fully functional (actually I left implementaton of SQRT, 1/x and % to you as an excercise) standard calculator but there is always room for improvement and visual styling. In this last section I will try to show you a simple sample for styling our keypad buttons and the TextViews we have used in our UI. For more information about Using Styles And Themes please visit this link.

### Applying Style To Our Keypad

Android has lots of different resource types and it is possible to style your Android application's UI at different levels by utilizing these resources. As a simple example, we will use Drawable resource type (to be more specific State List drawable resource type) for styling. You can check out this link for more resource types though.

First of all we have to define a State List drawable as an XML file under res/drawable. If you installed the latest Android SDK you will see drawable-hdpi, drawable-ldpi under res folder but there is no drawable folder. You can safely create a drawable folder if you do not already have one. After ensuring that drawable folder exists, add an XML file with name keypadclear1.xml. Inside keypadclear1.xml you will have the following markup code which defines a style for Button views.

```<?xml version="1.0" encoding="utf-8"?>
<selector

xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" >
<shape>

android:startColor="#ff8c00"

android:endColor="#FFFFFF"

android:angle="270" />
<stroke

android:width="2dp"

android:color="#dcdcdc" />
<corners

android:left="10dp"

android:top="10dp"

android:right="10dp"

android:bottom="10dp" />
</shape>
</item>

<item android:state_focused="true" >
<shape>

android:startColor="#ffc2b7"

android:endColor="#ffc2b7"

android:angle="270" />
<stroke

android:width="2dp"

android:color="#dcdcdc" />
<corners

android:left="10dp"

android:top="10dp"

android:right="10dp"

android:bottom="10dp" />
</shape>
</item>

<item>
<shape>

android:startColor="#ff9d77"

android:endColor="#ff9d77"

android:angle="270" />
<stroke

android:width="2dp"

<corners

android:left="10dp"

android:top="10dp"

android:right="10dp"

android:bottom="10dp" />
</shape>
</item>
</selector>```

keypadclear1.xml contains seperate style definitions for each of the three possible states of a Button view. Now that we have our State List drawable resource ready, we have to write some code to make use of this resource. We will set the background of keypad buttons of KeypadButtonCategory.CLEAR to be styled according to the definitions of keypadclear1.xml. We will modify getView method of our KeypadAdapter class slightly

```// create a new ButtonView for each item referenced by the Adapter
public View getView(int position, View convertView, ViewGroup parent) {
Button btn;
if (convertView == null) { // if it's not recycled, initialize some attributes

btn = new Button(mContext);

btn.setOnClickListener(mOnButtonClick);

// Set CalculatorButton enumeration as tag of the button so that we
// will use this information from our main view to identify what to do
} else {
btn = (Button) convertView;
}

btn.setText(mButtons[position].getText());
return btn;
}
```

On Line 13, we set the background resource of our Button views if they are categorized as KeypadButtonCategory.CLEAR and that is all, we have pinky rounded buttons  sketched as Area #9 in our mockup.

## Accomplishment

We got familiar with Android application development and evaluate different aspects of an Android application's UI. We developed a styled calculator which looks like the image atatched below

## Is There Room For Improvement In TouchCalculator?

Yes. There is always room for improvement and I intentionally left some business logic implementation to you. Here is the list of possible improvements

• Implement SQRT
• Implement 1/x (reciproc)
• Implement % (percent)
• Handle division by zero cases properly
• Implement different styles and provide "Switch Theme" dialog to the user
• Implement Scientific, Programmer and Statistics mode and allow user to switch modes

## Other Notes

How to fix Eclipse SDK 3.6 null pointer exception appearing when you try to edit res/values/strings.xml resource?

Open res\values\strings.xml with Text Editor and replace <resources> with <resources xmlns:android="http://schemas.android.com/apk/res/android">

## Share

- Software developer
- Has BS degree in Computer Engineering
- Has MBA degree
- Programmed with C, C++, Delphi, T-SQL and recently C#
- Little educational experience with Prolog
- Feel enthusiasm about NHibernate and LINQ
- Love to develop on Cuyahoga Web Framework
- Developer of PragmaSQL Editor
(Code Project Members Choice Winner for 2009 and 2010)
- Developed JiraTouch and MoodleTouch for iPhone

## You may also be interested in...

 Pro Pro

 First PrevNext
 Finally Evan Mason16-Nov-15 23:46 Evan Mason 16-Nov-15 23:46
 error Puneet Baranwal15-Nov-15 11:17 Puneet Baranwal 15-Nov-15 11:17
 Button location Member 116971805-Jul-15 12:17 Member 11697180 5-Jul-15 12:17
 good futurejo21-Oct-14 7:04 futurejo 21-Oct-14 7:04
 My vote of 2 webluke20-Jul-14 16:55 webluke 20-Jul-14 16:55
 Thanks for sharing. mijan9320-Apr-14 0:25 mijan93 20-Apr-14 0:25
 How to implement VAT calc Member 1044976513-Mar-14 3:19 Member 10449765 13-Mar-14 3:19
 Why??? Member 1060786518-Feb-14 20:01 Member 10607865 18-Feb-14 20:01
 keys display mixed up getView fixes Member 1046539620-Dec-13 8:49 Member 10465396 20-Dec-13 8:49
 change text color of gridview buttons Member 1020606415-Oct-13 21:20 Member 10206064 15-Oct-13 21:20
 Is this the right logic on how to commit the improvements? MaddieA22-Aug-13 20:09 MaddieA 22-Aug-13 20:09
 how to implement SQRT function upulwijayantha14-Aug-13 0:07 upulwijayantha 14-Aug-13 0:07
 My vote of 5 computervirus349-Jun-13 16:43 computervirus34 9-Jun-13 16:43
 My vote of 5 muratcantuna28-May-13 10:09 muratcantuna 28-May-13 10:09
 My vote of 5 VitorHugoGarcia20-May-13 0:38 VitorHugoGarcia 20-May-13 0:38
 Question about the code Dani21215-Mar-13 13:01 Dani2121 5-Mar-13 13:01
 Re: Question about the code Phat (Phillip) H. VU21-Apr-13 5:03 Phat (Phillip) H. VU 21-Apr-13 5:03
 problem Member 98731643-Mar-13 12:00 Member 9873164 3-Mar-13 12:00
 what is the code for sqrt,percentage and reciprocal in this article? Member 98151326-Feb-13 0:10 Member 9815132 6-Feb-13 0:10
 Re: what is the code for sqrt,percentage and reciprocal in this article? robzzzzz6-Feb-13 5:40 robzzzzz 6-Feb-13 5:40
 Business Logic Confusion Endbringer4224-Jan-13 17:06 Endbringer42 24-Jan-13 17:06
 I was doing pretty good until I got to the business logic section. There isn't an explanation as to what file all that code goes into nor where in the file. I'm assuming it goes in the Main.java file. Also, while typing the code in that section I keep getting the error "userInputText cannot be resolved". I don't see where this is defined anywhere in the file. `String text = keypadButton.getText().toString();` Is the string "text" in the line above supposed to be userInputText? This is my first Android app and Java app, so I could just be missing something simple.
 My vote of 5 VitorHugoGarcia8-Jan-13 22:35 VitorHugoGarcia 8-Jan-13 22:35
 Thank you, usefull example. Nap_BlownApart21-Nov-12 1:56 Nap_BlownApart 21-Nov-12 1:56
 My vote of 5 csharpbd3-Oct-12 18:51 csharpbd 3-Oct-12 18:51
 awesome iRakeshJha22-Sep-12 5:52 iRakeshJha 22-Sep-12 5:52
 My vote of 5 iRakeshJha22-Sep-12 5:51 iRakeshJha 22-Sep-12 5:51
 nice article vamp.bkstha12-Sep-12 7:37 vamp.bkstha 12-Sep-12 7:37
 Works Properly parkavikarthi15-Jul-12 23:06 parkavikarthi 15-Jul-12 23:06
 My vote of 5 wasiuddin8-Jul-12 6:12 wasiuddin 8-Jul-12 6:12
 one error please see urgently Akshit Jain27-Jun-12 21:18 Akshit Jain 27-Jun-12 21:18
 Well explained anjali john20-May-12 21:34 anjali john 20-May-12 21:34
 sqrt is not working veereshbabu20-Feb-12 20:45 veereshbabu 20-Feb-12 20:45
 TOUCHCALCULATOR Vaibhav17891-Feb-12 17:57 Vaibhav1789 1-Feb-12 17:57
 need help compiling it code00130-Jan-12 4:26 code001 30-Jan-12 4:26
 My vote of 5 darkagent2925-Dec-11 21:42 darkagent29 25-Dec-11 21:42
 My vote of 5 Habaner04-Dec-11 1:54 Habaner0 4-Dec-11 1:54
 where to place Key process cig779821-Oct-11 15:06 cig7798 21-Oct-11 15:06
 My vote of 5 Ernesto Herrera23-Jun-11 7:22 Ernesto Herrera 23-Jun-11 7:22
 Great tutorial! One minor suggestion... Goalstate19-May-11 13:39 Goalstate 19-May-11 13:39
 My vote of 5 joe_mycostech14-May-11 0:52 joe_mycostech 14-May-11 0:52
 Error, perhaps? DavidCrow7-Mar-11 10:12 DavidCrow 7-Mar-11 10:12
 How to get started in Android Developement Mick Leong28-Feb-11 17:05 Mick Leong 28-Feb-11 17:05
 Re: How to get started in Android Developement DavidCrow7-Mar-11 9:59 DavidCrow 7-Mar-11 9:59
 My vote of 4 Mick Leong28-Feb-11 16:59 Mick Leong 28-Feb-11 16:59
 My vote of 5 thatraja25-Feb-11 15:17 thatraja 25-Feb-11 15:17
 My vote of 5 chandu999928-Dec-10 1:22 chandu9999 28-Dec-10 1:22
 My vote of 5 paulsasik23-Dec-10 3:05 paulsasik 23-Dec-10 3:05
 My vote of 5 Zorance17-Dec-10 8:20 Zorance 17-Dec-10 8:20
 Last Visit: 31-Dec-99 18:00     Last Update: 20-Oct-17 1:32 Refresh 12 Next »