Skip to content

Instantly share code, notes, and snippets.

@protolif
Created March 16, 2012 23:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save protolif/2053693 to your computer and use it in GitHub Desktop.
Save protolif/2053693 to your computer and use it in GitHub Desktop.
NoMethodError: undefined method `width' for nil:NilClass
require 'ruboto/activity'
require 'ruboto/widget'
require 'ruboto/util/toast'
ruboto_import_widgets :Button, :TextView, :RelativeLayout
$activity.start_ruboto_activity "$sample_activity" do
setTitle 'Droidemo: A Ruboto Experiment'
def on_create(bundle)
self.content_view =
relative_layout(:id => 41, :layout => {:width= => :fill_parent}) do
@text_view = text_view :id => 42,
:text => 'Greetings, Outlander.'
@button = button :id => 43,
:text => "Pickpocket this NPC",
:width => :wrap_content,
:on_click_listener => @pick_pocket
end
#end
end
@pick_pocket = proc do |view|
@text_view.text = 'Guards! Arrest this thief.'
@button.text = 'Activate Stealth'
toast '24 Gold added.'
@button.on_click_listener = @activate_stealth
end
@activate_stealth = proc do |view|
@text_view.text = "Hey! Where'd he go?"
@button.text = "Pickpocket this NPC"
toast 'You disappear into nearby shadows.'
@button.on_click_listener = @pick_pocket
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment