Saturday, May 25, 2013

How to Download and Install Android Studio

This article describes how to download and install the 0.1 version of Android Studio on a Windows 7 computer.

At the recent Google IO conference, Google announced their new product for Android development: Android Studio.

Android Studio is meant to replace the Eclipse plugin for Android development. There has been a lot of excitement surrounding the tool--apparently many people are not huge fans of Eclipse. Personally, I am a fan of Eclipse, but certainly think that Android has gotten big enough to merit its own tool for development.

Version 0.1

It is important to remember that this is not a fully polished product, so there will be plenty of bugs and quirks. Google is simply releasing an early preview and labeling it version 0.1

Thursday, May 2, 2013

Android Tic Tac Toe Part 3

This is the third and final part of the tutorial series on creating a Tic-Tac-Toe application. See part one about the interfaces and part two about implementing the game logic.

1. Creating a Custom View for the Tiles

In a previous tutorial I described how you could create a custom view in Android that will take attributes and implement custom logic. This is the approach we will take for creating the full Tic Tac Toe application.

Saturday, March 30, 2013

Android Relative Layouts

This post briefly describes how to use Android Relative Layouts.

1. Why Use Relative Layouts?

One of the challenges when it comes to designing Android apps is making your app look presentable on a multitude of different Android devices with different screen sizes and resolutions. Relative layouts can help to place views in the proper locations without specifying an absolute position.

Thursday, March 21, 2013

Android Tic Tac Toe Game Logic - Part 2

In this section of the Tic Tac Toe tutorial we will implement several of the classes that we created in part one of the tutorial.

Implementing the GameManager Interface

The GameManager is responsible for handling the overall state of the game, including determining whether or not a move is valid and if the player or AI opponent has won the game. The implementation of the interface is posted below.

Tuesday, March 19, 2013

Android AsyncTasks (MultiThreading)

This tutorial explains what AsyncTasks are in Android, why you should use them, and demonstrates a simple app that calculates prime numbers to show them in action.

1. What is an AsyncTask and Why Should I use Them?

AsyncTasks are asynchronous because they operate in a thread separate from the UI thread.

You should use them to complete performance intensive tasks or tasks that may complete in an indefinite amount of time. If you do not, the user interface will be blocked until the task is finished.

For example: if you trying to download a huge web page, if you task is run in the UI thread you will prevent the application from respond to other actions--such as pressing other buttons, zooming, pressing the back button--and your app will be frozen.

No one likes it when an app completely freezes, even if it is doing legitimate loading/calculating work. Additionally, if your app blocks the UI thread for more than 20 or so seconds, the Android Operating System will assume it is broken, and a force-close dialog will appear.

Saturday, June 9, 2012

Android Shopping Cart Tutorial Part 3

In this part of the Android Shopping Cart Tutorial we will add prices, and calculate the total price for the purchase.


This tutorial is part of a series about building an android based shopping cart, and will build off of existing code and concepts discussed in Android Shopping Cart Tutorial and Android Shopping Cart Tutorial Part 2.

Step 1. Prices for Products

In our previous tutorials we learned how to display different products, add them to the cart, and even change the quantity of those products. Now we must add another crucial component, the price.

If you look back at the previous tutorials, our Product object already contains price information, and our initial catalog is setting prices--these prices simply are not being displayed in the app anywhere.

Tuesday, May 1, 2012

Creating a Custom View That Takes Attributes

This tutorial will demonstrate how to create a custom view that will change its appearance based on a custom attribute set in the xml layout.


1. Custom Attributes

If you have used Android Views in the layout editor, you are probably already familiar with setting attributes for views. For example, for an ImageView you can set the drawable attribute to determine what graphic to draw, or the Text Attribute for a button or label to determine what text will display.

If you find yourself designing a custom view, you may want to add custom attributes to that view that affect the display or behavior. For this example we will build off of the custom view that created before, and add an attribute to change the border color.