There is no setter for style on ProgressBar, so you have to set it at creation time in the constructor. Note that SplashActivity can conflict with the Ruboto SplashActivity.java, so I use another name (ProgressBarActivity)
require 'ruboto/widget'
require 'ruboto/util/toast'
ruboto_import_widgets :Button, :LinearLayout, :TextView, :ProgressBar
class ProgressBarActivity
AndroidAttr = JavaUtilities.get_proxy_class('android.R$attr')
def onCreate(bundle)
super
set_title 'some title here'
self.content_view =
linear_layout :orientation => :vertical do
@text_view = text_view :text => 'sample text.', :id => 42,
:layout => {:width => :match_parent},
:gravity => :center, :text_size => 18.0
button :text => 'foo',
:layout => {:width => :match_parent},
:id => 43, :on_click_listener => proc { bar }
@pb = ProgressBar.new(self, nil, AndroidAttr::progressBarStyleHorizontal)
@view_parent.add_view @pb
end
rescue Exception
puts "Exception creating activity: #{$!}"
puts $!.backtrace.join("\n")
end
def onResume
super
@pb.progress = @pb.max / 2
end
private
def bar
@text_view.text = 'things change.'
@pb.progress = 2 * @pb.max / 3
toast 'cha-ching!'
end
end