Wednesday, August 10, 2011

Layout of the Android Main.xml and friends

 

Being a Dot.Net programmer for several years now. It’s kinda hard downgrading back to good old eclipse and eclipse plugins.

 

It’s like watching RHPS at home, it’s the same except for all the bells and whistles. And tell ya the truth, You go to watch the show in the cinema because of the bells an whistles. Actually one would argue that without the bells and whistles throwing crap at each other, shouting APs and playing around with water pistols is damn right stupid – but I digress.

I found this site http://developer.android.com/guide/topics/ui/declaring-layout.html pretty useful to understand most of the technobabble about how to setup the vocab and the naming and stuff.

 

In general, if you want to work WITHIN the framework, you must learn these rules. ELSE? else you’re a regular programmer that fights the framework rather than embracing it and then shouting that M$ is just an evil system that doesn’t allow you to customize….

or in this case I guess it’s be G$$gle’s day in court vs the undisciplined programmers.

It’s kinda hard readjusting to setText vs .Text in properties and all this workaround shit.

too bad google went all NIH on us, and didn’t take a page out of the dot.net handbook.

had the added partial class life would’ve been sooo much simpler. this is like programming in 1995 again using tools designed to fight the good fight rather than tools to just WORK. I’ve half a mind to write my own hack to offer partial classes and point click services to the ADT – but I’m too lazy and underpaid for that. (or as I said before, I have only half a mind).

 

Back to the framework, and excuse my rants

So the layout file will contain a layout type located in the res/layout directory

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

             
android:orientation="vertical" >

   
<TextView android:id="@+id/text"
             
android:layout_width="wrap_content"
             
android:layout_height="wrap_content"
             
android:text="Hello, I am a TextView" />
   
<Button android:id="@+id/button"
           
android:layout_width="wrap_content"
           
android:layout_height="wrap_content"
           
android:text="Hello, I am a Button" />
</LinearLayout>


After you've declared your layout, you need to load it.



the default Activity loads a Layout of:




public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
}



I love it how the “main” is itallicized and bolded, soo cute donchathink ?



so how do we write the ID ? we write it using



<Button android:id=”@+id/my_Button” />



this will be created in the R.java respectfully.



on the onCreate() method you can reach the Button using



Button myButton  = (Button) findViewVyId(R.id.my_Button);



HELLO GOOGLE! WAKE UP



Dot.NET solved this is Dot.Net 2.0!



Specifically in ASP.NET. the xml parser the creates on the fly dot.net code? _Default.aspx class that locates the button and makes the connection ?



Why should I be writing automatic and seziphic code instead of programming my app? This is not something a programmer should be dealing with. this is something you should have written into your designer – oof.

Tuesday, August 09, 2011

Android SDK

 

Installing the android SDK and starting to write my android App

Installed Java 7

Installed Android SDK : FAILED

Added path vars

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Java\jdk1.7.0\bin\;

Installed SDK : PASSED

Eclipse Classic 3.7

http://www.eclipse.org/downloads/download.php?file=/eclipse/downloads/drops/R-3.7-201106131736/eclipse-SDK-3.7-win32.zip

ADT Plugin for eclispe

http://developer.android.com/sdk/eclipse-adt.html

 

Downloading the ADT Plugin

Use the Update Manager feature of your Eclipse installation to install the latest revision of ADT on your development computer.<>

Assuming that you have a compatible version of the Eclipse IDE installed, as described in Preparing for Installation, above, follow these steps to download the ADT plugin and install it in your Eclipse environment.

  1. Start Eclipse, then select Help > Install New Software....
  2. Click Add, in the top-right corner.
  3. In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and the following URL for the Location:
    http://dl-ssl.google.com/android/eclipse/
  4. Click OK
    Note: If you have trouble acquiring the plugin, try using "http" in the Location URL, instead of "https" (https is preferred for security reasons).
  5. In the Available Software dialog, select the checkbox next to Developer Tools and click Next.
  6. In the next window, you'll see a list of the tools to be downloaded. Click Next.
  7. Read and accept the license agreements, then click Finish.
    Note: If you get a security warning saying that the authenticity or validity of the software can't be established, click OK.
  8. When the installation completes, restart Eclipse.

Pasted from <http://developer.android.com/sdk/eclipse-adt.html>

 

image

image

Google USB Driver

http://developer.android.com/sdk/win-usb.html#WinUsbDriver

clip_image001

Setting up the enviroment

5. In the Variable Name field, type ANDROID.

6. Type the full path to the tools directory in the Variable Value field (see Figure 2-14).

clip_image001[5]

Create an AVD

To learn more about how to use AVDs and the options available to you, refer to the Android Virtual Devices document.

In this tutorial, you will run your application in the Android Emulator. Before you can launch the emulator, you must create an Android Virtual Device (AVD). An AVD defines the system image and device settings used by the emulator.

To create an AVD:

  1. In Eclipse, choose Window > Android SDK and AVD Manager.
  2. Select Virtual Devices in the left panel.
  3. Click New.

The Create New AVD dialog appears.

  1. Type the name of the AVD, such as "my_avd".
  2. Choose a target. The target is the platform (that is, the version of the Android SDK, such as 2.1) you want to run on the emulator.
  3. Click Skin: built In resolutions : QVGA

clip_image002

You can ignore the rest of the fields for now.

  1. Click Create AVD.

Pasted from <http://developer.android.com/resources/tutorials/hello-world.html>

Droid Draw

  • Not needed for now – I think it’s a standalone project made prior to the ADT ?

ANDROID SOURCE CODE

http://source.android.com/source/downloading.html

couldn’t download this. tried to download Git and other stuff, just ended with a headache. NEXT

 

My Next post … Hello world