Ruboto

https://www.engineyard.com/video/16286183

Ruboto is an android development framework for ruby, and I’m playing around it for a while. The above video has a nice introduction though it’s a little old one.

My major motivation for this at the moment is to rejuvenate the Nexus7, which I impulsively got some time ago. I’ve tried PhoneGap (Cordova) which provides web-based application framework, but it didn’t fit well for me (I may prefer server-side one if it’s just a web-application). So, it’s my next trial.

https://github.com/ruboto/ruboto/wiki

I tried some using examples in the wiki, but I barely managed to write the following. Mostly, I keep seeing the “Unformtunately XXX has stopped” message. I may need more understanding of android frameworks, before pursuing further.

require 'ruboto/widget'
require 'ruboto/util/toast'

ruboto_import_widgets :Button, :LinearLayout, :TextView, :EditText, :RadioGroup, :RadioButton

class QuickStartActivity
  def on_create(bundle)
    super
    set_title 'Ruboto Sample'

    self.content_view =
      linear_layout :orientation => :vertical do
        @text_view = text_view :text => 'What would you like to order?'

        @radio_group = radio_group do
          radio_button :text => "Tuna",    :id => 0
          radio_button :text => "Trout",   :id => 1
          radio_button :text => "Salmon",  :id => 2
          radio_button :text => "Crab",    :id => 3
          radio_button :text => "Lobster", :id => 4
        end
        @quantity = edit_text :hint => "Quantity"
        button :text => "Place Order", :on_click_listener => proc { place_order }
      end
  rescue
    puts "Exception creating activity: #{$!}"
    puts $!.backtrace.join("\n")
  end

  private

  def place_order
    if @radio_group.checked_radio_button_id != -1
      selection = @radio_group.child_at(@radio_group.checked_radio_button_id).text
      toast "Order placed for #{@quantity.text} items of #{selection}"
    else
      toast "Please select item to order"
    end
  end
end

ruboto_sample

Advertisements

Posted on March 17, 2013, in Ruby. Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: