Category Archives: xml

Working on a facelift

Howdy all,

Jon and I aren’t graphic designers, actually I just ran into this problem at work,  and it’s pretty obvious this app isn’t going to be the prettiest bell at the ball.  Whatever, form follows function.  Right now I’m working on making the ‘create activity’ section contain everything we’re going to need Calendar style date picker, notes, title, priority radio buttons and that should be it for now.

I’ve ran into a bit of a problem with saving the tasks and I can’t figure out why they aren’t being recreated on restart for now I’m just leaving it alone (which is why nothing has been committed yet).  Since Jon built most of the onRestart() I’m sure he’ll know what’s wrong once we meet THIS SUNDAY FOR SURE so I’m not too concerned.  I found out today that the GUI for android dev is terrific, it really is.  I was fussing around with all the ugly xml and switched over only to see the GUI version was so smooth and easy to use.

From the blog jamescelona » WSU CS by jamescelona and used with permission of the author. All other rights reserved by the author.

The basics of an Android app

Learning the structure of an Android app is overwhelming at first, but it’s not too difficult after some familiarization. I recommend using Lars Vogel’s excellent Android tutorials here. They are among the best tutorials I have found, and I am sure I will keep using them as a reference as this project continues.

An Android app is made up of two parts: the front end and the back end. The front end is the visual part of the app that the user interacts with, and the back end, which contains all the code that drives the app.

The front end is written using XML. I have never used XML before, but it is very similar to HTML in that it is a markup language that uses nested tags as its programming structure. Android uses several XML files to create the app’s front end. There is at least one XML layout file for each activity (or several if you are supporting multiple device sizes), as well as layout files for custom views. XML is also used to define constant strings that will be placed in the layouts, such as the text on a button.

The back end is written in Java, which is great because it is a language that I am very familiar with. You can use the Java standard library in addition to the Android library when coding your app. This gives you access to a ton of pre-made objects, and the APIs are thoroughly documented online by Oracle and Google.

Each screen in an app is known as an activity. Activities are classes that you extend from a base activity class. Each activity is tied to an XML layout file which provides the front end visuals. Activities are created, resumed, and closed by the Android OS through a series of callback methods, which are called automatically by the OS at the appropriate times. Some examples of callback methods: onCreate, onPause, onResume, onStop. These methods have to be overwritten for your activity to work correctly.

Information sent between activities is called an intent. Intents carry standard data like strings or can be modified to carry custom extra data. For example, our AddTaskActivity creates a new Task object, adds it to an intent, and sends it back to the MainActivity where it will be displayed for the user.

There are other basics, such as fragments, services, and notifications, but I don’t know enough about them yet. I’ll comment on those after I’ve learned them!

From the blog Code Your Enthusiasm » WSU CS by Jon and used with permission of the author. All other rights reserved by the author.

My First App

I never mentioned in my previous post that I have been watching www.thenewboston.org ‘s video series throughout the past few weeks.  He’s a young guy and it’s kind of funny learning from him sometimes, weird little things bother me sometimes, I’m weird, it’s weird.  But!

I wrote my first app, you can push a button to add or push a button to subtract! Can’t wait to publish it to Google play..  It’s a good building block to start from.

————————————-

<?xml version=”1.0″ encoding=”utf-8″?>
<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android&#8221;
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
android:orientation=”vertical” >

<TextView
android:id=”@+id/tvDisplay”
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:layout_gravity=”center”
android:gravity=”center”
android:text=”Total =”
android:textSize=”45dp” />

<Button
android:id=”@+id/addButton”
android:layout_width=”250dp”
android:layout_height=”wrap_content”
android:layout_gravity=”center”
android:text=”Add One”
android:textSize=”20dp” />
<Button
android:id=”@+id/subButton”
android:layout_width=”244dp”
android:layout_height=”wrap_content”
android:layout_gravity=”center”
android:text=”Subtract One”
android:textSize=”20dp” />

</LinearLayout>

——————–

Does wordpress not have a <code> tag? Gross.

But, that’s XML a lot of referencing android:layout, or just android in general, who would have thunk it?!  XML seems pretty straight forward, oddly enough the day after I learned some of it I had to write it a bit for my internship, which was pretty cool.

From the blog jamescelona » WSU CS by jamescelona and used with permission of the author. All other rights reserved by the author.

First Week install/configure

It’s been a slow start to the project, nice weather tends to do that to me.  I manged to find a great video series about Android development that really starts from the ground up.  Actually, it’s kind of boring at times when he begins to talk about what’s going on in the Java code he’s typing, the XML I am lost but the Java is pretty straight forward (for now).

I have mixed feelings about using Eclipse for this project, I think it will come in handy most of the time but, it’s really bloated.  I like Gedit, or I guess notepad++ for windows.

I watched the first videos, downloaded Eclipse, downloaded everything I needed, John wants to work on Android 4.03 since his phone will be able to use it.  It’s going to work fine but, just won’t be available to as many people considering it’s a much newer version than the API level 8 that was suggested in the video series.   The videos came in handy since I thought it was always kind of a pain in the neck to set up Eclipse in Java.

It’s pretty convenient that I am learning XML because I had to use it recently at my job, and knew where I was because of watching a few videos.

From the blog jamescelona » WSU CS by jamescelona and used with permission of the author. All other rights reserved by the author.