Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ruboto Introduction at Google Developers Group Oslo Meetup

Ruboto Introduction at Google Developers Group Oslo Meetup

Learn how to develop apps on Android using the RUby language and libraries. Ruboto uses JRuby to run your Ruby based app and to give you access to all the Ruby, Java, and Android libraries available.

Uwe Kubosch

January 23, 2013
Tweet

More Decks by Uwe Kubosch

Other Decks in Programming

Transcript

  1. 1
    Saturday, January 26, 13

    View full-size slide

  2. Ruboto
    JRuby on Android
    1
    Saturday, January 26, 13

    View full-size slide

  3. Uwe Kubosch
    Work at Datek Wireless in
    Norway
    Ruboto core developer
    JRuby rookie committer
    2
    Saturday, January 26, 13

    View full-size slide

  4. Ruboto?
    Platform for developing
    Android apps using Ruby
    Builds on JRuby and the
    Android SDK
    Application and component
    generators
    Test framework
    Compact GUI definition
    3
    Saturday, January 26, 13

    View full-size slide

  5. _why Ruboto?
    Write Ruby instead of
    Java/XML
    Use Ruby libraries (gems)
    Focus on testing
    Faster development cycles
    4
    Saturday, January 26, 13

    View full-size slide

  6. Topics covered
    History
    Ruboto IRB
    Installation & development
    tools
    Hello world!
    Demos
    Limitations
    Roadmap
    5
    Saturday, January 26, 13

    View full-size slide

  7. Activity: A screen
    View: A screen component
    Service: Background process
    Intent: Definition of action
    BroadcastReceiver: Listener for Intents
    Android basics/terms
    6
    Saturday, January 26, 13

    View full-size slide

  8. History 2009
    PoC by Charles Nutter
    (headius) February 24,
    2009
    ruboto-irb by headius
    August 1, 2009
    7
    Saturday, January 26, 13

    View full-size slide

  9. History 2009
    PoC by Charles Nutter
    (headius) February 24,
    2009
    ruboto-irb by headius
    August 1, 2009
    7
    Saturday, January 26, 13

    View full-size slide

  10. History 2009
    PoC by Charles Nutter
    (headius) February 24,
    2009
    ruboto-irb by headius
    August 1, 2009
    7
    Saturday, January 26, 13

    View full-size slide

  11. History 2009
    PoC by Charles Nutter
    (headius) February 24,
    2009
    ruboto-irb by headius
    August 1, 2009
    7
    Saturday, January 26, 13

    View full-size slide

  12. History 2009
    PoC by Charles Nutter
    (headius) February 24,
    2009
    ruboto-irb by headius
    August 1, 2009
    7
    Saturday, January 26, 13

    View full-size slide

  13. Demo: OpenGL
    8
    Saturday, January 26, 13

    View full-size slide

  14. Demo: OpenGL
    class Cube
    def initialize
    one = 0x10000
    vertices = [
    -one,-one,-one,one,-one,-one,one,one,-one,-one,one,-one,-one,-
    one,one,one,-one,one,one,one,one,-one,one,one
    ]
    colors = [
    0,0,0,one,one,0,0,one,one,one,0,one,0,one,0,one,
    0,0,one,one,one,0,one,one,one,one,one,one,0,one,one,one
    ]
    indices = [
    0, 4, 5, 0, 5, 1, 1, 5, 6, 1, 6, 2, 2, 6, 7, 2, 7, 3, 3, 7, 4,
    3, 4, 0, 4, 7, 6, 4, 6, 5, 3, 0, 1, 3, 1, 2
    ]
    vbb = ByteBuffer.allocateDirect(vertices.length*4)
    vbb.order(ByteOrder.nativeOrder)
    @vertex_buffer = vbb.asIntBuffer
    @vertex_buffer.put(vertices.to_java(:int))
    @vertex_buffer.position(0)
    cbb = ByteBuffer.allocateDirect(colors.length*4)
    cbb.order(ByteOrder.nativeOrder)
    @color_buffer = cbb.asIntBuffer
    @color_buffer.put(colors.to_java(:int))
    @color_buffer.position(0)
    @index_buffer = ByteBuffer.allocateDirect(indices.length)
    @index_buffer.put(indices.to_java(:byte))
    @index_buffer.position(0)
    end
    def draw(gl)
    gl.glFrontFace(GL10::GL_CW)
    gl.glVertexPointer(3, GL10::GL_FIXED, 0, @vertex_buffer)
    gl.glColorPointer(4, GL10::GL_FIXED, 0, @color_buffer)
    gl.glDrawElements(GL10::GL_TRIANGLES, 36, GL10::GL_UNSIGNED_BYTE,
    @index_buffer)
    end
    end
    class RubotoGLSurfaceViewRenderer
    def initialize
    @translucent_background = false
    @cube = Cube.new
    @angle = 0.0
    @offset = 1.2
    end
    def onDrawFrame(gl)
    gl.glClear(GL10::GL_COLOR_BUFFER_BIT | GL10::GL_DEPTH_BUFFER_BIT)
    gl.glMatrixMode(GL10::GL_MODELVIEW)
    gl.glLoadIdentity
    gl.glTranslatef(0, 0, -3.0)
    gl.glRotatef(@angle, 0, 1, 0)
    gl.glRotatef(@angle*0.25, 1, 0, 0)
    gl.glEnableClientState(GL10::GL_VERTEX_ARRAY)
    gl.glEnableClientState(GL10::GL_COLOR_ARRAY)
    @cube.draw(gl)
    gl.glRotatef(@angle*2.0, 0, 1, 1)
    gl.glTranslatef(0.5, 0.5, 0.5)
    @cube.draw(gl)
    @angle += @offset
    end
    def onSurfaceChanged(gl, width, height)
    gl.glViewport(0, 0, width, height)
    ratio = width.to_f / height.to_f
    gl.glMatrixMode(GL10::GL_PROJECTION)
    gl.glLoadIdentity
    gl.glFrustumf(-ratio, ratio, -1, 1, 1, 10)
    end
    def onSurfaceCreated(gl, config)
    gl.glDisable(GL10::GL_DITHER)
    gl.glHint(GL10::GL_PERSPECTIVE_CORRECTION_HINT, GL10::GL_FASTEST)
    if (@translucent_background)
    gl.glClearColor(0,0,0,0)
    else
    gl.glClearColor(1,1,1,1)
    end
    gl.glEnable(GL10::GL_CULL_FACE)
    gl.glShadeModel(GL10::GL_SMOOTH)
    gl.glEnable(GL10::GL_DEPTH_TEST)
    end
    def changeAngle
    @offset = -@offset
    end
    end
    ruboto_generate(android.opengl.GLSurfaceView => "TouchSurfaceView")
    class TouchSurfaceView
    def initialize(context)
    super context
    self.initialize_ruboto_callbacks do
    def on_touch_event(event)
    if event.getAction == MotionEvent::ACTION_DOWN
    @renderer.changeAngle
    request_render
    end
    return true
    end
    end
    end
    def renderer= renderer
    @renderer = renderer
    super renderer
    end
    end
    $activity.start_ruboto_activity "$glsurface" do
    setTitle "GLSurfaceView"
    def on_create(bundle)
    @surface_view = TouchSurfaceView.new(self)
    @surface_view.renderer = RubotoGLSurfaceViewRenderer.new
    self.content_view = @surface_view
    end
    def on_resume
    @surface_view.on_resume
    end
    def on_pause
    @surface_view.on_pause
    end
    end
    8
    Saturday, January 26, 13

    View full-size slide

  15. Demo: OpenGL
    9
    Saturday, January 26, 13

    View full-size slide

  16. History 2010
    ruboto-core : GSoC 2010 by Daniel Jackoway
    Version 0.0.3 released December 19, 2010
    10
    Saturday, January 26, 13

    View full-size slide

  17. History 2011
    Testing framework: Feb 13,
    2011 (my first contribution)
    Bundler support: may 21,
    2011
    New Logo & Icons by
    RedNifre: july 20, 2011
    RubotoCore platform
    package: august 2011
    Rename to just “ruboto”:
    december 24, 2011
    11
    Saturday, January 26, 13

    View full-size slide

  18. History 2011
    Testing framework: Feb 13,
    2011 (my first contribution)
    Bundler support: may 21,
    2011
    New Logo & Icons by
    RedNifre: july 20, 2011
    RubotoCore platform
    package: august 2011
    Rename to just “ruboto”:
    december 24, 2011
    11
    Saturday, January 26, 13

    View full-size slide

  19. History 2012
    Class oriented component definition, 2012
    On-device generation of subclasses may 10,
    2012
    Subclassing of Java classes (next release)
    12
    Saturday, January 26, 13

    View full-size slide

  20. History 2012
    Class oriented component definition, 2012
    On-device generation of subclasses may 10,
    2012
    Subclassing of Java classes (next release)
    $activity.handle_create do |bundle|
    setTitle ‘Hello World!’
    setup_content do
    linear_layout :orientation => LinearLayout::VERTICAL do
    @text_view = text_view :text => 'What hath Matz wrought?'
    button :text => ‘Click me!’, :width => :wrap_content, :id => 43
    end
    end
    handle_click do |view|
    if view.id == 43
    @text_view.setText 'What hath Matz wrought!'
    toast 'Flipped a bit via butterfly'
    end
    end
    end
    12
    Saturday, January 26, 13

    View full-size slide

  21. History 2012
    Class oriented component definition, 2012
    On-device generation of subclasses may 10,
    2012
    Subclassing of Java classes (next release)
    $activity.handle_create do |bundle|
    setTitle ‘Hello World!’
    setup_content do
    linear_layout :orientation => LinearLayout::VERTICAL do
    @text_view = text_view :text => 'What hath Matz wrought?'
    button :text => ‘Click me!’, :width => :wrap_content, :id => 43
    end
    end
    handle_click do |view|
    if view.id == 43
    @text_view.setText 'What hath Matz wrought!'
    toast 'Flipped a bit via butterfly'
    end
    end
    end
    $activity.start_ruboto_activity do
    def on_create(bundle)
    setTitle ‘Hello World!’
    click_handler = proc do |view|
    @text_view.setText 'What hath Matz wrought!'
    toast 'Flipped a bit via butterfly'
    end
    self.content_view =
    linear_layout :orientation => LinearLayout::VERTICAL do
    @text_view = text_view :text => 'What hath Matz wrought?'
    button :text => ‘Click me!, :width => :wrap_content,
    :on_click_listener => click_handler
    end
    end
    end
    12
    Saturday, January 26, 13

    View full-size slide

  22. History 2012
    Class oriented component definition, 2012
    On-device generation of subclasses may 10,
    2012
    Subclassing of Java classes (next release)
    $activity.handle_create do |bundle|
    setTitle ‘Hello World!’
    setup_content do
    linear_layout :orientation => LinearLayout::VERTICAL do
    @text_view = text_view :text => 'What hath Matz wrought?'
    button :text => ‘Click me!’, :width => :wrap_content, :id => 43
    end
    end
    handle_click do |view|
    if view.id == 43
    @text_view.setText 'What hath Matz wrought!'
    toast 'Flipped a bit via butterfly'
    end
    end
    end
    $activity.start_ruboto_activity do
    def on_create(bundle)
    setTitle ‘Hello World!’
    click_handler = proc do |view|
    @text_view.setText 'What hath Matz wrought!'
    toast 'Flipped a bit via butterfly'
    end
    self.content_view =
    linear_layout :orientation => LinearLayout::VERTICAL do
    @text_view = text_view :text => 'What hath Matz wrought?'
    button :text => ‘Click me!, :width => :wrap_content,
    :on_click_listener => click_handler
    end
    end
    end
    class ImageButtonActivity
    def on_create(bundle)
    super
    set_title ‘Hello World!’
    click_handler = proc do |view|
    @text_view.setText 'What hath Matz wrought!'
    toast 'Flipped a bit via butterfly'
    end
    self.content_view =
    linear_layout :orientation => :vertical do
    @text_view = text_view :text => 'What hath Matz wrought?'
    button :text => ‘Click me!’, :width => :wrap_content, :id => 43,
    :on_click_listener => click_handler
    end
    end
    end
    12
    Saturday, January 26, 13

    View full-size slide

  23. History 2012
    Class oriented component definition, 2012
    On-device generation of subclasses may 10,
    2012
    Subclassing of Java classes (next release)
    13
    Saturday, January 26, 13

    View full-size slide

  24. History 2012
    Class oriented component definition, 2012
    On-device generation of subclasses may 10,
    2012
    Subclassing of Java classes (next release)
    require 'ruboto/generate'
    ruboto_generate("android.widget.ArrayAdapter" => $package_name + ".MyArrayAdapter")
    adapter = MyArrayAdapter.new(self, android.R.layout.simple_list_item_1 , [...])
    adapter.initialize_ruboto_callbacks do
    def get_view(position, convert_view, parent)
    @inflater ||= context.getSystemService(Context::LAYOUT_INFLATER_SERVICE)
    row = convert_view ? convert_view : @inflater.inflate(mResource, nil)
    row.findViewById(mFieldId).text = get_item(position)
    row
    end
    end
    13
    Saturday, January 26, 13

    View full-size slide

  25. History 2012
    Class oriented component definition, 2012
    On-device generation of subclasses may 10,
    2012
    Subclassing of Java classes (next release)
    require 'ruboto/generate'
    ruboto_generate("android.widget.ArrayAdapter" => $package_name + ".MyArrayAdapter")
    adapter = MyArrayAdapter.new(self, android.R.layout.simple_list_item_1 , [...])
    adapter.initialize_ruboto_callbacks do
    def get_view(position, convert_view, parent)
    @inflater ||= context.getSystemService(Context::LAYOUT_INFLATER_SERVICE)
    row = convert_view ? convert_view : @inflater.inflate(mResource, nil)
    row.findViewById(mFieldId).text = get_item(position)
    row
    end
    end
    class MyArrayAdapter < android.widget.ArrayAdapter
    def get_view(position, convert_view, parent)
    @inflater ||= context.getSystemService(Context::LAYOUT_INFLATER_SERVICE)
    row = convert_view ? convert_view : @inflater.inflate(mResource, nil)
    row.findViewById(mFieldId).text = get_item(position)
    row
    end
    end
    adapter = MyArrayAdapter.new(self, android.R.layout.simple_list_item_1, [...])
    13
    Saturday, January 26, 13

    View full-size slide

  26. Installation
    Android toolset: Java JDK, Apache ANT,
    Android SDK + Platform SDK
    A Ruby implementation
    [sudo] gem install ruboto
    14
    Saturday, January 26, 13

    View full-size slide

  27. Tooling
    The “ruboto” command
    Rake
    15
    Saturday, January 26, 13

    View full-size slide

  28. Tooling - create project
    ruboto gen app --package my.cool.super_app
    16
    Saturday, January 26, 13

    View full-size slide

  29. Tooling - create project
    The “ruboto” command
    ruboto gem app --package my.cool.
    Rake based
    $ ruboto gen app --package my.cool.super_app
    Generating Android app SuperApp in /Users/uwe/workspace/jruby/super_app...
    ...
    Added file super_app/src/my/cool/super_app/SuperAppActivity.java
    ...
    Added file super_app/res/values/strings.xml
    Added file super_app/res/layout/main.xml
    Added file super_app/AndroidManifest.xml
    Added file super_app/build.xml
    Added file super_app/proguard-project.txt
    Removed file src/my/cool/super_app/SuperAppActivity.java
    Removed file res/layout/main.xml
    ...
    Added file /Users/uwe/workspace/jruby/super_app/src/my/cool/super_app/SuperAppActivity.java.
    Added file /Users/uwe/workspace/jruby/super_app/src/super_app_activity.rb.
    Added file /Users/uwe/workspace/jruby/super_app/test/src/super_app_activity_test.rb.
    17
    Saturday, January 26, 13

    View full-size slide

  30. Tooling - create component
    ruboto gen class Activity --name MyActivity
    18
    Saturday, January 26, 13

    View full-size slide

  31. Tooling - create component
    ruboto gen class Activity --name MyActivity
    $ ruboto gen class Activity --name MyActivity
    Added file /Users/uwe/workspace/jruby/hello_world/src/presentation/hello_world/MyActivity.java.
    Added file /Users/uwe/workspace/jruby/hello_world/src/my_activity.rb.
    Added file /Users/uwe/workspace/jruby/hello_world/test/src/my_activity_test.rb.
    Added activity to manifest.
    19
    Saturday, January 26, 13

    View full-size slide

  32. Tooling - build APK
    rake debug
    rake release
    20
    Saturday, January 26, 13

    View full-size slide

  33. Tooling - Install and run APK
    rake install
    rake start
    rake install start
    rake update_scripts:restart
    21
    Saturday, January 26, 13

    View full-size slide

  34. http://download.eclipse.org/
    releases/juno
    https://dl-ssl.google.com/
    android/eclipse/
    Eclipse
    22
    Saturday, January 26, 13

    View full-size slide

  35. http://download.eclipse.org/
    releases/juno
    https://dl-ssl.google.com/
    android/eclipse/
    Eclipse
    23
    Saturday, January 26, 13

    View full-size slide

  36. GUI Editor
    Eclipse
    24
    Saturday, January 26, 13

    View full-size slide

  37. Hello World!
    25
    Saturday, January 26, 13

    View full-size slide

  38. Hello world!
    26
    Saturday, January 26, 13

    View full-size slide

  39. Hello world!
    $ android create project --target android-8 --path hello_world --package presentation.hello_world --activity HelloWorldActivity
    Generates file src/presentation/HelloWorldActivity.java
    26
    Saturday, January 26, 13

    View full-size slide

  40. Hello world!
    $ android create project --target android-8 --path hello_world --package presentation.hello_world --activity HelloWorldActiv
    Generates file src/presentation/HelloWorldActivity.java
    26
    Saturday, January 26, 13

    View full-size slide

  41. Hello world!
    $ android create project --target android-8 --pat...
    Generates file src/presentation/HelloWorldActivity.java
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.View;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_hello_world);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(R.id.textView1);
    tv.setText("Hello JavaZone!");
    }
    }
    27
    Saturday, January 26, 13

    View full-size slide

  42. Hello world!
    $ android create project --target android-8 --pat...
    Generates file src/presentation/HelloWorldActivity.java
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.View;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_hello_world);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(R.id.textView1);
    tv.setText("Hello JavaZone!");
    }
    }

    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center" >
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:text="@string/hello_world"
    tools:context=".HelloWorldActivity"
    android:textSize="46dip" />
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:layout_marginTop="75dp"
    android:onClick="changeIt"
    android:text="Say hello" />

    27
    Saturday, January 26, 13

    View full-size slide

  43. Hello world!
    $ android create project --target android-8 --pat...
    Generates file src/presentation/HelloWorldActivity.java
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.View;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_hello_world);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(R.id.textView1);
    tv.setText("Hello JavaZone!");
    }
    }
    27
    Saturday, January 26, 13

    View full-size slide

  44. Hello world!
    $ android create project --target android-8 --pat...
    Generates file src/presentation/HelloWorldActivity.java
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.View;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_hello_world);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(R.id.textView1);
    tv.setText("Hello JavaZone!");
    }
    }
    $ android create project --target android-8 --pat...
    Generates file src/presentation/HelloWorldActivity.java
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.View;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_hello_world);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(R.id.textView1);
    tv.setText("Hello JavaZone!");
    }
    }
    28
    Saturday, January 26, 13

    View full-size slide

  45. Hello world!
    $ android create project --target android-8 --pat...
    Generates file src/presentation/HelloWorldActivity.java
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.View;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_hello_world);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(R.id.textView1);
    tv.setText("Hello JavaZone!");
    }
    }
    $ android create project --target android-8 --pat...
    Generates file src/presentation/HelloWorldActivity.java
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.View;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_hello_world);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(R.id.textView1);
    tv.setText("Hello JavaZone!");
    }
    }
    28
    Saturday, January 26, 13

    View full-size slide

  46. Hello world!
    $ android create project --target android-8 --pat...
    Generates file src/presentation/HelloWorldActivity.java
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.View;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_hello_world);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(R.id.textView1);
    tv.setText("Hello JavaZone!");
    }
    }
    $ android create project --target android-8 --pat...
    Generates file src/presentation/HelloWorldActivity.java
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.View;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_hello_world);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(R.id.textView1);
    tv.setText("Hello JavaZone!");
    }
    }
    29
    Saturday, January 26, 13

    View full-size slide

  47. Hello world!
    $ android create project --target android-8 --pat...
    Generates file src/presentation/HelloWorldActivity.java
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.View;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_hello_world);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(R.id.textView1);
    tv.setText("Hello JavaZone!");
    }
    }
    $ android create project --target android-8 --pat...
    Generates file src/presentation/HelloWorldActivity.java
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.View;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_hello_world);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(R.id.textView1);
    tv.setText("Hello JavaZone!");
    }
    }
    $ ruboto gen app --package presentation.hello_world
    Generates file src/hello_world_activity.rb
    29
    Saturday, January 26, 13

    View full-size slide

  48. Hello world!
    $ android create project --target android-8 --pat...
    Generates file src/presentation/HelloWorldActivity.java
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.View;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_hello_world);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(R.id.textView1);
    tv.setText("Hello JavaZone!");
    }
    }
    $ android create project --target android-8 --pat...
    Generates file src/presentation/HelloWorldActivity.java
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.View;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_hello_world);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(R.id.textView1);
    tv.setText("Hello JavaZone!");
    }
    }
    $ ruboto gen app --package presentation.hello_world
    Generates file src/hello_world_activity.rb
    29
    Saturday, January 26, 13

    View full-size slide

  49. Hello world!
    $ ruboto gen app --package presentation.hello_world
    Generates file src/hello_world_activity.rb
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.View;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_hello_world);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(R.id.textView1);
    tv.setText("Hello JavaZone!");
    }
    }
    $ android create project --target android-8 --pat...
    Generates file src/presentation/HelloWorldActivity.java
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.View;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_hello_world);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(R.id.textView1);
    tv.setText("Hello JavaZone!");
    }
    }
    30
    Saturday, January 26, 13

    View full-size slide

  50. package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.View;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstance State);
    setContentView(R.layout.activity_hello_world);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(R.id.textView1);
    tv.setText("Hello JavaZone!");
    }
    }
    Hello world!
    class HelloWorldActivity
    def on_create(bundle)
    super
    setContentView R.layout.activity_hello_world
    end
    def change_it(view)
    tv = findViewById(AndroidIds::textView1)
    tv.text = "Hello JavaZone!"
    end
    end
    31
    Saturday, January 26, 13

    View full-size slide

  51. Hello world!
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center" >
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:text="@string/hello_world"
    tools:context=".HelloWorldActivity"
    android:textSize="46dip" />
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:layout_marginTop="75dp"
    android:onClick="changeIt"
    android:text="Say hello" />

    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.View;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstance State);
    setContentView(R.layout.activity_hello_world);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(R.id.textView1);
    tv.setText("Hello JavaZone!");
    }
    }
    32
    Saturday, January 26, 13

    View full-size slide

  52. xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center" >
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:text="@string/hello_world"
    tools:context=".HelloWorldActivity"
    android:textSize="46dip" />
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:layout_marginTop="75dp"
    android:onClick="changeIt"
    android:text="Say hello" />

    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.View;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstance State);
    setContentView(R.layout.activity_hello_world);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(R.id.textView1);
    tv.setText("Hello JavaZone!");
    }
    }
    33
    Saturday, January 26, 13

    View full-size slide

  53. package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    @Override
    public void onClick(View v) {
    changeIt(v);
    }
    }
    34
    Saturday, January 26, 13

    View full-size slide

  54. package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    @Override
    public void onClick(View v) {
    changeIt(v);
    }
    }
    35
    Saturday, January 26, 13

    View full-size slide

  55. package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    @Override
    public void onClick(View v) {
    changeIt(v);
    }
    }
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    @Override
    public void onClick(View v) {
    changeIt(v);
    }
    }
    36
    Saturday, January 26, 13

    View full-size slide

  56. package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    @Override
    public void onClick(View v) {
    changeIt(v);
    }
    }
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    @Override
    public void onClick(View v) {
    changeIt(v);
    }
    }
    37
    Saturday, January 26, 13

    View full-size slide

  57. package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    @Override
    public void onClick(View v) {
    changeIt(v);
    }
    }
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    @Override
    public void onClick(View v) {
    changeIt(v);
    }
    }
    38
    Saturday, January 26, 13

    View full-size slide

  58. import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    @Override
    public void onClick(View v) {
    changeIt(v);
    }
    }
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    @Override
    public void onClick(View v) {
    changeIt(v);
    }
    }
    39
    Saturday, January 26, 13

    View full-size slide

  59. import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    @Override
    public void onClick(View v) {
    changeIt(v);
    }
    }
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    @Override
    public void onClick(View v) {
    changeIt(v);
    }
    }
    40
    Saturday, January 26, 13

    View full-size slide

  60. import android.app.Activity;
    import android.view.Gravity;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    class HelloWorldActivity extends Activity implements
    OnClickListener
    public onCreate( savedInstanceState) {
    super.onCreate(savedInstanceState);
    layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    btn = new Button(this);
    btn.setText("Say hello");
    btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public changeIt( view) {
    tv = findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    public onClick( v) {
    changeIt(v);
    }
    end
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    @Override
    public void onClick(View v) {
    changeIt(v);
    }
    }
    41
    Saturday, January 26, 13

    View full-size slide

  61. import android.app.Activity;
    import android.view.Gravity;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    class HelloWorldActivity extends Activity implements
    OnClickListener
    public onCreate( savedInstanceState) {
    super.onCreate(savedInstanceState);
    layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    btn = new Button(this);
    btn.setText("Say hello");
    btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public changeIt( view) {
    tv = findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    public onClick( v) {
    changeIt(v);
    }
    end
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    @Override
    public void onClick(View v) {
    changeIt(v);
    }
    }
    42
    Saturday, January 26, 13

    View full-size slide

  62. import android.app.Activity;
    import android.view.Gravity;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    class HelloWorldActivity extends Activity implements
    OnClickListener
    def onCreate( savedInstanceState)
    super.onCreate(savedInstanceState);
    layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    btn = new Button(this);
    btn.setText("Say hello");
    btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    end
    def changeIt( view)
    tv = findViewById(42);
    tv.setText("Hello JavaZone!");
    end
    def onClick( v)
    changeIt(v);
    end
    end
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    ! @Override
    ! public void onClick(View v) {
    ! ! changeIt(v);
    ! }
    }
    43
    Saturday, January 26, 13

    View full-size slide

  63. import android.app.Activity;
    import android.view.Gravity;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    class HelloWorldActivity extends Activity implements
    OnClickListener
    def onCreate( savedInstanceState)
    super.onCreate(savedInstanceState);
    layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    btn = new Button(this);
    btn.setText("Say hello");
    btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    end
    def changeIt( view)
    tv = findViewById(42);
    tv.setText("Hello JavaZone!");
    end
    def onClick( v)
    changeIt(v);
    end
    end
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    ! @Override
    ! public void onClick(View v) {
    ! ! changeIt(v);
    ! }
    }
    44
    Saturday, January 26, 13

    View full-size slide

  64. import android.app.Activity;
    import android.view.Gravity;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    class HelloWorldActivity extends Activity implements
    OnClickListener
    def onCreate( savedInstanceState)
    super.onCreate(savedInstanceState);
    layout = LinearLayout.new(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    tv = TextView.new(this);
    tv.setId(42);
    tv.setText("Hello World!");
    tvlp = LayoutParams.new(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    btn = Button.new(this);
    btn.setText("Say hello");
    btnlp = LayoutParams.new(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    end
    def changeIt( view)
    tv = findViewById(42);
    tv.setText("Hello JavaZone!");
    end
    def onClick( v)
    changeIt(v);
    end
    end
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    ! @Override
    ! public void onClick(View v) {
    ! ! changeIt(v);
    ! }
    }
    45
    Saturday, January 26, 13

    View full-size slide

  65. import android.app.Activity;
    import android.view.Gravity;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    class HelloWorldActivity extends Activity implements
    OnClickListener
    def onCreate( savedInstanceState)
    super.onCreate(savedInstanceState);
    layout = LinearLayout.new(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    tv = TextView.new(this);
    tv.setId(42);
    tv.setText("Hello World!");
    tvlp = LayoutParams.new(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    btn = Button.new(this);
    btn.setText("Say hello");
    btnlp = LayoutParams.new(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    end
    def changeIt( view)
    tv = findViewById(42);
    tv.setText("Hello JavaZone!");
    end
    def onClick( v)
    changeIt(v);
    end
    end
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    ! @Override
    ! public void onClick(View v) {
    ! ! changeIt(v);
    ! }
    }
    46
    Saturday, January 26, 13

    View full-size slide

  66. import android.app.Activity;
    import android.view.Gravity;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    class HelloWorldActivity extends Activity implements
    OnClickListener
    def onCreate( savedInstanceState)
    super.onCreate(savedInstanceState);
    layout = LinearLayout.new(self);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    tv = TextView.new(self);
    tv.setId(42);
    tv.setText("Hello World!");
    tvlp = LayoutParams.new(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    btn = Button.new(self);
    btn.setText("Say hello");
    btnlp = LayoutParams.new(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(self);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    end
    def changeIt( view)
    tv = findViewById(42);
    tv.setText("Hello JavaZone!");
    end
    def onClick( v)
    changeIt(v);
    end
    end
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    ! @Override
    ! public void onClick(View v) {
    ! ! changeIt(v);
    ! }
    }
    47
    Saturday, January 26, 13

    View full-size slide

  67. import android.app.Activity;
    import android.view.Gravity;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    class HelloWorldActivity extends Activity implements
    OnClickListener
    def onCreate( savedInstanceState)
    super.onCreate(savedInstanceState);
    layout = LinearLayout.new(self);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    tv = TextView.new(self);
    tv.setId(42);
    tv.setText("Hello World!");
    tvlp = LayoutParams.new(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    btn = Button.new(self);
    btn.setText("Say hello");
    btnlp = LayoutParams.new(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(self);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    end
    def changeIt( view)
    tv = findViewById(42);
    tv.setText("Hello JavaZone!");
    end
    def onClick( v)
    changeIt(v);
    end
    end
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    ! @Override
    ! public void onClick(View v) {
    ! ! changeIt(v);
    ! }
    }
    48
    Saturday, January 26, 13

    View full-size slide

  68. import android.app.Activity;
    import android.view.Gravity;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    class HelloWorldActivity < Activity
    def onCreate( savedInstanceState)
    super;
    layout = LinearLayout.new(self);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    tv = TextView.new(self);
    tv.setId(42);
    tv.setText("Hello World!");
    tvlp = LayoutParams.new(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    btn = Button.new(self);
    btn.setText("Say hello");
    btnlp = LayoutParams.new(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(self);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    end
    def changeIt( view)
    tv = findViewById(42);
    tv.setText("Hello JavaZone!");
    end
    def onClick( v)
    changeIt(v);
    end
    end
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    ! @Override
    ! public void onClick(View v) {
    ! ! changeIt(v);
    ! }
    }
    49
    Saturday, January 26, 13

    View full-size slide

  69. import android.app.Activity;
    import android.view.Gravity;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    class HelloWorldActivity < Activity
    def onCreate( savedInstanceState)
    super;
    layout = LinearLayout.new(self);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    tv = TextView.new(self);
    tv.setId(42);
    tv.setText("Hello World!");
    tvlp = LayoutParams.new(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    btn = Button.new(self);
    btn.setText("Say hello");
    btnlp = LayoutParams.new(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(self);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    end
    def changeIt( view)
    tv = findViewById(42);
    tv.setText("Hello JavaZone!");
    end
    def onClick( v)
    changeIt(v);
    end
    end
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    ! @Override
    ! public void onClick(View v) {
    ! ! changeIt(v);
    ! }
    }
    50
    Saturday, January 26, 13

    View full-size slide

  70. import android.app.Activity;
    import android.view.Gravity;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    class HelloWorldActivity < Activity
    def onCreate( savedInstanceState)
    super;
    layout = LinearLayout.new(self);
    layout.setGravity(Gravity::CENTER);
    layout.setOrientation(LinearLayout::VERTICAL);
    tv = TextView(self).new;
    tv.setId(42);
    tv.setText("Hello World!");
    tvlp = LayoutParams.new(
    LayoutParams::WRAP_CONTENT,
    LayoutParams::WRAP_CONTENT);
    tvlp.gravity = Gravity::CENTER;
    tv.setTextSize(46);
    btn = Button.new(self);
    btn.setText("Say hello");
    btnlp = LayoutParams.new(
    LayoutParams::WRAP_CONTENT,
    LayoutParams::WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity::CENTER;
    btn.setOnClickListener(self);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    end
    def changeIt( view)
    tv = findViewById(42);
    tv.setText("Hello JavaZone!");
    end
    def onClick( v)
    changeIt(v);
    end
    end
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    ! @Override
    ! public void onClick(View v) {
    ! ! changeIt(v);
    ! }
    }
    51
    Saturday, January 26, 13

    View full-size slide

  71. import android.app.Activity;
    import android.view.Gravity;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    class HelloWorldActivity < Activity
    def onCreate(savedInstanceState)
    super;
    layout = LinearLayout.new(self);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    tv = TextView.new(self);
    tv.setId(42);
    tv.setText("Hello World!");
    tvlp = LayoutParams.new(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    btn = Button.new(self);
    btn.setText("Say hello");
    btnlp = LayoutParams.new(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(self);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    end
    def changeIt(view)
    tv = findViewById(42);
    tv.setText("Hello JavaZone!");
    end
    def onClick(v)
    changeIt(v);
    end
    end
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    ! @Override
    ! public void onClick(View v) {
    ! ! changeIt(v);
    ! }
    }
    52
    Saturday, January 26, 13

    View full-size slide

  72. import android.app.Activity;
    import android.view.Gravity;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    class HelloWorldActivity < Activity
    def onCreate(savedInstanceState)
    super;
    layout = LinearLayout.new(self);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    tv = TextView.new(self);
    tv.setId(42);
    tv.setText("Hello World!");
    tvlp = LayoutParams.new(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    btn = Button.new(self);
    btn.setText("Say hello");
    btnlp = LayoutParams.new(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(self);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    end
    def changeIt(view)
    tv = findViewById(42);
    tv.setText("Hello JavaZone!");
    end
    def onClick(v)
    changeIt(v);
    end
    end
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    ! @Override
    ! public void onClick(View v) {
    ! ! changeIt(v);
    ! }
    }
    53
    Saturday, January 26, 13

    View full-size slide

  73. import android.app.Activity
    import android.view.Gravity
    import android.widget.Button
    import android.widget.LinearLayout
    import android.widget.LinearLayout.LayoutParams
    import android.widget.TextView
    class HelloWorldActivity < Activity
    def onCreate(savedInstanceState)
    super
    layout = LinearLayout.new(self)
    layout.setGravity(Gravity.CENTER)
    layout.setOrientation(LinearLayout.VERTICAL)
    tv = TextView.new(self)
    tv.setId(42)
    tv.setText("Hello World!")
    tvlp = LayoutParams.new(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT)
    tvlp.gravity = Gravity.CENTER
    tv.setTextSize(46)
    btn = Button.new(self)
    btn.setText("Say hello")
    btnlp = LayoutParams.new(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT)
    btnlp.topMargin = 75
    btnlp.gravity = Gravity.CENTER
    btn.setOnClickListener(self)
    layout.addView(tv, tvlp)
    layout.addView(btn, btnlp)
    setContentView(layout)
    end
    def changeIt(view)
    tv = findViewById(42)
    tv.setText("Hello JavaZone!")
    end
    def onClick(v)
    changeIt(v)
    end
    end
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    ! @Override
    ! public void onClick(View v) {
    ! ! changeIt(v);
    ! }
    }
    54
    Saturday, January 26, 13

    View full-size slide

  74. import android.app.Activity
    import android.view.Gravity
    import android.widget.Button
    import android.widget.LinearLayout
    import android.widget.LinearLayout.LayoutParams
    import android.widget.TextView
    class HelloWorldActivity < Activity
    def onCreate(savedInstanceState)
    super
    layout = LinearLayout.new(self)
    layout.setGravity(Gravity.CENTER)
    layout.setOrientation(LinearLayout.VERTICAL)
    tv = TextView.new(self)
    tv.setId(42)
    tv.setText("Hello World!")
    tvlp = LayoutParams.new(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT)
    tvlp.gravity = Gravity.CENTER
    tv.setTextSize(46)
    btn = Button.new(self)
    btn.setText("Say hello")
    btnlp = LayoutParams.new(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT)
    btnlp.topMargin = 75
    btnlp.gravity = Gravity.CENTER
    btn.setOnClickListener(self)
    layout.addView(tv, tvlp)
    layout.addView(btn, btnlp)
    setContentView(layout)
    end
    def changeIt(view)
    tv = findViewById(42)
    tv.setText("Hello JavaZone!")
    end
    def onClick(v)
    changeIt(v)
    end
    end
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    ! @Override
    ! public void onClick(View v) {
    ! ! changeIt(v);
    ! }
    }
    55
    Saturday, January 26, 13

    View full-size slide

  75. import android.view.Gravity
    import android.widget.Button
    import android.widget.LinearLayout
    import android.widget.LinearLayout.LayoutParams
    import android.widget.TextView
    class HelloWorldActivity
    def onCreate(savedInstanceState)
    super
    layout = LinearLayout.new(self)
    layout.setGravity(Gravity.CENTER)
    layout.setOrientation(LinearLayout.VERTICAL)
    tv = TextView.new(self)
    tv.setId(42)
    tv.setText("Hello World!")
    tvlp = LayoutParams.new(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT)
    tvlp.gravity = Gravity.CENTER
    tv.setTextSize(46)
    btn = Button.new(self)
    btn.setText("Say hello")
    btnlp = LayoutParams.new(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT)
    btnlp.topMargin = 75
    btnlp.gravity = Gravity.CENTER
    btn.setOnClickListener(self)
    layout.addView(tv, tvlp)
    layout.addView(btn, btnlp)
    setContentView(layout)
    end
    def changeIt(view)
    tv = findViewById(42)
    tv.setText("Hello JavaZone!")
    end
    def onClick(v)
    changeIt(v)
    end
    end
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    ! @Override
    ! public void onClick(View v) {
    ! ! changeIt(v);
    ! }
    }
    56
    Saturday, January 26, 13

    View full-size slide

  76. import android.view.Gravity
    import android.widget.Button
    import android.widget.LinearLayout
    import android.widget.LinearLayout.LayoutParams
    import android.widget.TextView
    class HelloWorldActivity
    def onCreate(savedInstanceState)
    super
    layout = LinearLayout.new(self)
    layout.setGravity(Gravity.CENTER)
    layout.setOrientation(LinearLayout.VERTICAL)
    tv = TextView.new(self)
    tv.setId(42)
    tv.setText("Hello World!")
    tvlp = LayoutParams.new(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT)
    tvlp.gravity = Gravity.CENTER
    tv.setTextSize(46)
    btn = Button.new(self)
    btn.setText("Say hello")
    btnlp = LayoutParams.new(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT)
    btnlp.topMargin = 75
    btnlp.gravity = Gravity.CENTER
    btn.setOnClickListener(self)
    layout.addView(tv, tvlp)
    layout.addView(btn, btnlp)
    setContentView(layout)
    end
    def changeIt(view)
    tv = findViewById(42)
    tv.setText("Hello JavaZone!")
    end
    def onClick(v)
    changeIt(v)
    end
    end
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    ! @Override
    ! public void onClick(View v) {
    ! ! changeIt(v);
    ! }
    }
    57
    Saturday, January 26, 13

    View full-size slide

  77. import android.view.Gravity
    import android.widget.Button
    import android.widget.LinearLayout
    import android.widget.LinearLayout.LayoutParams
    import android.widget.TextView
    class HelloWorldActivity
    def on_create(savedInstanceState)
    super
    layout = LinearLayout.new(self)
    layout.gravity = Gravity.CENTER
    layout.orientation = LinearLayout.VERTICAL
    tv = TextView.new(self)
    tv.id = 42
    tv.text = "Hello World!"
    tvlp = LayoutParams.new(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT)
    tvlp.gravity = Gravity.CENTER
    tv.text_size = 46
    btn = Button.new(self)
    btn.text = "Say hello"
    btnlp = LayoutParams.new(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT)
    btnlp.topMargin = 75
    btnlp.gravity = Gravity.CENTER
    btn.on_click_listener = self
    layout.add_view(tv, tvlp)
    layout.add_view(btn, btnlp)
    setContentView(layout)
    end
    def change_it(view)
    tv = find_view_by_id(42)
    tv.text = "Hello JavaZone!"
    end
    def on_click(v)
    change_it(v)
    end
    end
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    ! @Override
    ! public void onClick(View v) {
    ! ! changeIt(v);
    ! }
    }
    58
    Saturday, January 26, 13

    View full-size slide

  78. import android.view.Gravity
    import android.widget.Button
    import android.widget.LinearLayout
    import android.widget.LinearLayout.LayoutParams
    import android.widget.TextView
    class HelloWorldActivity
    def on_create(savedInstanceState)
    super
    layout = LinearLayout.new(self)
    layout.gravity = Gravity.CENTER
    layout.orientation = LinearLayout.VERTICAL
    tv = TextView.new(self)
    tv.id = 42
    tv.text = "Hello World!"
    tvlp = LayoutParams.new(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT)
    tvlp.gravity = Gravity.CENTER
    tv.text_size = 46
    btn = Button.new(self)
    btn.text = "Say hello"
    btnlp = LayoutParams.new(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT)
    btnlp.topMargin = 75
    btnlp.gravity = Gravity.CENTER
    btn.on_click_listener = self
    layout.add_view(tv, tvlp)
    layout.add_view(btn, btnlp)
    setContentView(layout)
    end
    def change_it(view)
    tv = find_view_by_id(42)
    tv.text = "Hello JavaZone!"
    end
    def on_click(v)
    change_it(v)
    end
    end
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    ! @Override
    ! public void onClick(View v) {
    ! ! changeIt(v);
    ! }
    }
    59
    Saturday, January 26, 13

    View full-size slide

  79. import android.view.Gravity
    import android.widget.Button
    import android.widget.LinearLayout
    import android.widget.LinearLayout.LayoutParams
    import android.widget.TextView
    class HelloWorldActivity
    def on_create(savedInstanceState)
    super
    layout = LinearLayout.new(self)
    layout.gravity = Gravity.CENTER
    layout.orientation = LinearLayout.VERTICAL
    tv = TextView.new(self)
    tv.id = 42
    tv.text = "Hello World!"
    tvlp = LayoutParams.new(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT)
    tvlp.gravity = Gravity.CENTER
    tv.text_size = 46
    btn = Button.new(self)
    btn.text = "Say hello"
    btnlp = LayoutParams.new(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT)
    btnlp.topMargin = 75
    btnlp.gravity = Gravity.CENTER
    btn.on_click_listener = self
    layout.add_view(tv, tvlp)
    layout.add_view(btn, btnlp)
    setContentView(layout)
    end
    def change_it(view)
    tv = find_view_by_id(42)
    tv.text = "Hello JavaZone!"
    end
    def on_click(v)
    change_it(v)
    end
    end
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    ! @Override
    ! public void onClick(View v) {
    ! ! changeIt(v);
    ! }
    }
    60
    Saturday, January 26, 13

    View full-size slide

  80. require 'ruboto/widget'
    ruboto_import_widgets :Button, :LinearLayout, :TextView
    class HelloWorldActivity
    def on_create(savedInstanceState)
    super
    self.content_view =
    linear_layout gravity: :center, orientation: :vertical do
    text_view text: 'Hello World!', id: 42,
    text_size: 46, width: :wrap_content,
    height: :wrap_content, gravity: :center
    button id: 43, text: "Say hello", width: :wrap_content,
    height: :wrap_content, gravity: :center,
    margins: [0,75,0,0],
    on_click_listener: self
    end
    end
    def change_it(view)
    tv = find_view_by_id(42)
    tv.text = "Hello JavaZone!"
    end
    def on_click(v)
    change_it(v)
    end
    end
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    ! @Override
    ! public void onClick(View v) {
    ! ! changeIt(v);
    ! }
    }
    61
    Saturday, January 26, 13

    View full-size slide

  81. require 'ruboto/widget'
    ruboto_import_widgets :Button, :LinearLayout, :TextView
    class HelloWorldActivity
    def on_create(savedInstanceState)
    super
    self.content_view =
    linear_layout gravity: :center, orientation: :vertical do
    text_view text: 'Hello World!', id: 42,
    text_size: 46, width: :wrap_content,
    height: :wrap_content, gravity: :center
    button id: 43, text: "Say hello", width: :wrap_content,
    height: :wrap_content, gravity: :center,
    margins: [0,75,0,0],
    on_click_listener: self
    end
    end
    def change_it(view)
    tv = find_view_by_id(42)
    tv.text = "Hello JavaZone!"
    end
    def on_click(v)
    change_it(v)
    end
    end
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    ! @Override
    ! public void onClick(View v) {
    ! ! changeIt(v);
    ! }
    }
    62
    Saturday, January 26, 13

    View full-size slide

  82. require 'ruboto/widget'
    ruboto_import_widgets :Button, :LinearLayout, :TextView
    class HelloWorldActivity
    def on_create(savedInstanceState)
    super
    self.content_view =
    linear_layout gravity: :center, orientation: :vertical do
    text_view text: 'Hello World!', id: 42,
    text_size: 46, width: :wrap_content,
    height: :wrap_content, gravity: :center
    button id: 43, text: "Say hello", width: :wrap_content,
    height: :wrap_content, gravity: :center,
    margins: [0,75,0,0],
    on_click_listener: self
    end
    end
    def change_it(view)
    tv = find_view_by_id(42)
    tv.text = "Hello JavaZone!"
    end
    def on_click(v)
    change_it(v)
    end
    end
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    ! @Override
    ! public void onClick(View v) {
    ! ! changeIt(v);
    ! }
    }
    63
    Saturday, January 26, 13

    View full-size slide

  83. require 'ruboto/widget'
    ruboto_import_widgets :Button, :LinearLayout, :TextView
    class HelloWorldActivity
    def on_create(savedInstanceState)
    super
    self.content_view =
    linear_layout gravity: :center, orientation: :vertical do
    text_view text: 'Hello World!', id: 42,
    text_size: 46, width: :wrap_content,
    height: :wrap_content, gravity: :center
    button id: 43, text: "Say hello", width: :wrap_content,
    height: :wrap_content, gravity: :center,
    margins: [0,75,0,0],
    on_click_listener: self
    end
    end
    def change_it(view)
    tv = find_view_by_id(42)
    tv.text = "Hello JavaZone!"
    end
    def on_click(v)
    change_it(v)
    end
    end
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    ! @Override
    ! public void onClick(View v) {
    ! ! changeIt(v);
    ! }
    }
    64
    Saturday, January 26, 13

    View full-size slide

  84. require 'ruboto/widget'
    ruboto_import_widgets :Button, :LinearLayout, :TextView
    class HelloWorldActivity
    def on_create(savedInstanceState)
    super
    self.content_view =
    linear_layout gravity: :center, orientation: :vertical do
    @tv = text_view text: 'Hello World!', id: 42,
    text_size: 46, width: :wrap_content,
    height: :wrap_content, gravity: :center
    button id: 43, text: "Say hello", width: :wrap_content,
    height: :wrap_content, gravity: :center,
    margins: [0,75,0,0],
    on_click_listener: proc{@tv.text = ‘Hello JavaZone’}
    end
    end
    end
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    ! @Override
    ! public void onClick(View v) {
    ! ! changeIt(v);
    ! }
    }
    65
    Saturday, January 26, 13

    View full-size slide

  85. require 'ruboto/widget'
    ruboto_import_widgets :Button, :LinearLayout, :TextView
    class HelloWorldActivity
    def on_create(savedInstanceState)
    super
    self.content_view =
    linear_layout gravity: :center, orientation: :vertical do
    @tv = text_view text: 'Hello World!', id: 42,
    text_size: 46, width: :wrap_content,
    height: :wrap_content, gravity: :center
    button id: 43, text: 'Say hello', width: :wrap_content,
    height: :wrap_content, gravity: :center,
    margins: [0,75,0,0],
    on_click_listener: proc{@tv.text = 'Hello JavaZone'}
    end
    end
    end
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    ! @Override
    ! public void onClick(View v) {
    ! ! changeIt(v);
    ! }
    }
    66
    Saturday, January 26, 13

    View full-size slide

  86. require 'ruboto/widget'
    ruboto_import_widgets :Button, :LinearLayout, :TextView
    class HelloWorldActivity
    def on_create(savedInstanceState)
    super
    self.content_view =
    linear_layout gravity: :center, orientation: :vertical do
    @tv = text_view text: 'Hello World!', id: 42,
    text_size: 46, width: :wrap_content,
    height: :wrap_content, gravity: :center
    button id: 43, text: 'Say hello', width: :wrap_content,
    height: :wrap_content, gravity: :center,
    margins: [0,75,0,0],
    on_click_listener: proc{@tv.text = 'Hello JavaZone'}
    end
    end
    end
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    ! @Override
    ! public void onClick(View v) {
    ! ! changeIt(v);
    ! }
    }
    67
    Saturday, January 26, 13

    View full-size slide

  87. require 'ruboto/widget'
    ruboto_import_widgets :Button, :LinearLayout, :TextView
    class HelloWorldActivity
    def on_create(savedInstanceState)
    super
    self.content_view =
    linear_layout gravity: :center, orientation: :vertical do
    @tv = text_view text: 'Hello World!', id: 42,
    text_size: 46, width: :wrap_content,
    height: :wrap_content, gravity: :center
    button id: 43, text: 'Say hello', width: :wrap_content,
    height: :wrap_content, gravity: :center,
    margins: [0,75,0,0],
    on_click_listener: proc{@tv.text = 'Hello JavaZone'}
    end
    end
    end
    package com.example.examplejavaxml;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Gravity;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.LinearLayout;
    import android.widget.LinearLayout.LayoutParams;
    import android.widget.TextView;
    public class HelloWorldActivity extends Activity implements
    OnClickListener {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout layout = new LinearLayout(this);
    layout.setGravity(Gravity.CENTER);
    layout.setOrientation(LinearLayout.VERTICAL);
    TextView tv = new TextView(this);
    tv.setId(42);
    tv.setText("Hello World!");
    LayoutParams tvlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    tvlp.gravity = Gravity.CENTER;
    tv.setTextSize(46);
    Button btn = new Button(this);
    btn.setText("Say hello");
    LayoutParams btnlp = new LayoutParams(
    LayoutParams.WRAP_CONTENT,
    LayoutParams.WRAP_CONTENT);
    btnlp.topMargin = 75;
    btnlp.gravity = Gravity.CENTER;
    btn.setOnClickListener(this);
    layout.addView(tv, tvlp);
    layout.addView(btn, btnlp);
    setContentView(layout);
    }
    public void changeIt(View view) {
    TextView tv = (TextView) findViewById(42);
    tv.setText("Hello JavaZone!");
    }
    ! @Override
    ! public void onClick(View v) {
    ! ! changeIt(v);
    ! }
    }
    67
    Saturday, January 26, 13

    View full-size slide

  88. Examples
    Make a call
    Show webpage
    Spycam
    68
    Saturday, January 26, 13

    View full-size slide

  89. Display a web page
    import "android.content.Intent"
    import "android.net.Uri"
    class RubotoHomePageActivity
    def on_resume
    intent = Intent.new(Intent::ACTION_VIEW)
    uri = Uri.parse("http://ruboto.org/")
    intent.setData(uri)
    startActivity(intent)
    finish
    end
    end
    69
    Saturday, January 26, 13

    View full-size slide

  90. Phone home
    import "android.content.Intent"
    import "android.net.Uri"
    class PhoneHomeActivity
    def on_resume
    intent = Intent.new(Intent::ACTION_CALL)
    uri = Uri.parse("tel:5551234")
    intent.setData(uri)
    startActivity(intent)
    finish
    end
    enda
    70
    Saturday, January 26, 13

    View full-size slide

  91. Spycam
    Access the camera
    Show the camera image
    Start a WEBrick web server
    Serve a new image on each
    request
    71
    Saturday, January 26, 13

    View full-size slide

  92. Spycam
    Access the camera
    Show the camera image
    Start a WEBrick web server
    Serve a new image on each
    request
    require  'monitor'
    require  'camera_helper'
    require  'ruboto/util/stack'
    class  SpycamServer
       extend  MonitorMixin
       PORT  =  4567
       DOC_ROOT  =  "#{$activity.files_dir.absolute_path}/"
       @@server  =  nil
       def  self.start(activity,  server_status_view)
           Thread.with_large_stack(512)  do
               synchronize  do
                   if  @@server.nil?
                       activity.run_on_ui_thread  {  server_status_view.text  =  
    "Loading"  }
                       require  'webrick'
                       activity.run_on_ui_thread  {  server_status_view.text  =  
    "Loaded"  }
                       @@server  =  WEBrick::HTTPServer.new(:Port  =>  
    PORT,  :DocumentRoot  =>  DOC_ROOT)
                       @@server.mount_proc('/')  do  |req,  resp|
                           case  req.path
                           when  '/',  'index.html'
                               CameraHelper.take_picture(activity)
                               resp.content_type  =  "text/html"
                               resp.body  =  '
                                                               
                                                                   Spycam
                                                               
                                                               
                                                                   
                                                               
                                                           '
                               raise  WEBrick::HTTPStatus::OK
                           when  '/latest.jpg'
                               resp.content_type  =  "image/jpg"
                               resp.body  =  $camera_data
                               $camera_data  =  nil
                               raise  WEBrick::HTTPStatus::OK
                           else
                               resp.body  =  "Unknown  path:  #{req.path.inspect}"
                               raise  WEBrick::HTTPStatus::NotFound
                           end
                       end
                       server  =  @@server
                       Thread.new{server.start}
                   end
                   activity.run_on_ui_thread  {  server_status_view.text  =  "WEBrick  
    require  'ruboto/activity'
    require  'ruboto/widget'
    require  'spycam_server'
    import  android.util.Log
    import  android.view.Surface
    import  android.view.WindowManager
    ruboto_import_widgets  :Button,  :LinearLayout,  :ScrollView,  :TextView
    ruboto_import_widget  :SurfaceView,  "android.view"
    class  SpycamActivity
       def  on_create(bundle)
           rotation  =  {
                   Surface::ROTATION_0  =>  0,Surface::ROTATION_90  =>  
    90,Surface::ROTATION_180  =>  180,Surface::ROTATION_270  =>  270
           }[window_manager.default_display.rotation]
           self.title  =  "Spycam  #{rotation}"
           #  
    self.setRequestedOrientation(android.content.pm.ActivityInfo::SCREEN_OR
    IENTATION_PORTRAIT)
           window.add_flags(WindowManager::LayoutParams::FLAG_KEEP_SCREEN_ON)
           setContentView(linear_layout(:orientation  =>  :vertical)  do
               linear_layout  do
                   text_view  :text  =>  "Server:  "
                   @server_status_view  =  text_view
               end
               linear_layout  do
                   text_view  :text  =>  "Picture:  "
                   @camera_status_view  =  text_view
               end
               sv  =  surface_view
               sv.holder.add_callback  RubotoSurfaceHolderCallback.new(rotation)
               #  Deprecated,  but  still  required  for  older  API  version
               sv.holder.set_type  
    android.view.SurfaceHolder::SURFACE_TYPE_PUSH_BUFFERS
           end)
       end
       
       def  set_camera_status(value)
           @camera_status_view.text  =  value
       end
       def  camera_status=(value)
           run_on_ui_thread  {  $activity.set_camera_status  value  }
       end
       def  on_resume  
           SpycamServer.start(self,  @server_status_view)
    class  CameraHelper
       def  self.take_picture(activity)
           activity.camera_status  =  "Set  volume..."
           am  =  
    activity.getSystemService(android.content.Context::AUDIO_SERVICE)
           old_volume  =  
    am.get_stream_volume(android.media.AudioManager::STREAM_SYSTEM)
           am.set_stream_volume(android.media.AudioManager::STREAM_SYSTEM,  0,  
    0)
           activity.camera_status  =  "Taking  picture..."
           picture_taken  =  false
           $camera.take_picture(nil,  nil)  do  |data,  camera|
               $camera_data  =  String.from_java_bytes(data)
               activity.camera_status  =  "Gotcha!"
               $camera.start_preview
               am.set_stream_volume(android.media.AudioManager::STREAM_SYSTEM,  
    old_volume,  0)
               picture_taken  =  true
           end
           sleep  0.1  until  picture_taken
       end
    end
    71
    Saturday, January 26, 13

    View full-size slide

  93. Demo: Spycam
    72
    Saturday, January 26, 13

    View full-size slide

  94. Limitations
    Startup time
    Tiny stack on main thread
    Runtime size
    No AOT/JIT compilation
    73
    Saturday, January 26, 13

    View full-size slide

  95. Status
    Ruboto is in production!
    Monthly releases.
    Still improving the API
    Support Android 2.1 - 4.2
    5 active developers, more welcome!
    74
    Saturday, January 26, 13

    View full-size slide

  96. Status
    Ruboto is in production!
    Monthly releases.
    Still improving the API
    Support Android 2.1 - 4.2
    5 active developers, more welcome!
    74
    Saturday, January 26, 13

    View full-size slide

  97. Status
    Ruboto is in production!
    Monthly releases.
    Still improving the API
    Support Android 2.1 - 4.2
    5 active developers, more welcome!
    74
    Saturday, January 26, 13

    View full-size slide

  98. Roadmap
    1.0.0 release this year
    Dalvik backend for the IR compiler
    AOT Compilation / IR Persistence
    Mirah integration ( http://www.mirah.org )
    FFI support
    Eclipse plugin
    75
    Saturday, January 26, 13

    View full-size slide

  99. Demo (if time allows)
    Ruboto IRB Server
    76
    Saturday, January 26, 13

    View full-size slide

  100. Contributors welcome!
    ruboto.org
    77
    Saturday, January 26, 13

    View full-size slide

  101. Questions?
    78
    Saturday, January 26, 13

    View full-size slide

  102. Thank you!
    79
    Saturday, January 26, 13

    View full-size slide