tags:

views:

94

answers:

1

I am a cameraman and I want to make an app for my Moto Droid that will calculate my depth of field given four inputs. I am literally brand new to javascript and this programming stuff, so I was wondering if anyone could help me out.

I have a very basic GUI set up using Droiddraw which allows me to input my 4 variables, which are:

Focus (@+id/focust)

Focal Length (@+id/flt)

Aperture (@+id/apt)

Circle of Confusion (@+id/coct)

Equations for this calculation are located here: http://www.dofmaster.com/equations.html

for example...

to get hyperfocal distance I need to get: ((f^2)/(N*c))+f

all of these variables will be drawn from inputs in the GUI, but I don't know how to call them, how to write the actual math, and how to address the results so I can make them appear in the "results area" on the bottom of the screen.

I've never done java before and I only want to make this app because the existing ones don't fit my needs. Can someone help?

Thanks!

A: 

If I'm not mistaken, DroidDraw is a tool for building the XML user interface description used by the Java API. If you want to program for Android in JavaScript, something like PhoneGap might be a better choice. It lets you build real Android application using HTML and JavaScript.

On the other hand, if you want to use the XML and Java APIs, then you should probably run through the Android tutorials. The first one is Hello, World.

Since you're just getting started with programming, I can't stress tutorials enough. It's true that your idea shouldn't be too hard to implement, but you need to understand the basics first.


I don't mean to give the impression that one style (PhoneGap vs. Java and XML) is better. For your purposes, either should be fine. It's more a question of what you prefer. Java/XML is the paradigm supported by Google, and provides access to more functionality. On the other hand, if you already know HTML or JavaScript (or are interested in learning them), PhoneGap will certainly provide everything you need. I think PhoneGap is also intended to make it easier for beginners, though I haven't used it, so I don't know how successful they have been.

The XML file that is generated by DroidDraw can't be used within PhoneGap. If you do choose to use PhoneGap, then you will need to build the interface in HTML. You might be able to use something like DreamWeaver or FrontPage or one of any number of HTML editors to help you with this step.

The XML file is just a description of an interface. When you start your application, the Android platform uses this description to build the user interface that you see. Once that has happened, you can move data from the interface to Java, or from Java to the interface, without any hassle. You certainly won't be limited by the XML interface description - it's pretty flexible.

If you've been going through the Android tutorials, then it might be best to forget that I even mentioned PhoneGap. It's a wildly different alternative that is the right choice for some people and some applications. But the Android tutorials won't help you to understand it. I only brought it up because you mentioned JavaScript in your original post.

Daniel Yankowsky
Thanks for the reply!I have done a few of the basic tutorials, which has gotten me to the point I am at right now. How exactly does an .xml interface limit me? Is it not possible to call values entered in an xml interface into the java file of the application?
Sean