Progress bar in indeterminate mode

36 views
Skip to first unread message

Kosmas Chatzimichalis

unread,
Nov 15, 2012, 9:46:44 AM11/15/12
to rub...@googlegroups.com
Hi,

Any help with trying to use a progress bar (dialog?) with an indeterminate mode (circle spinning) while a thread attached to the  main UI thread is doing some processing?

Thanks

Scott Moyer

unread,
Nov 15, 2012, 2:04:52 PM11/15/12
to rub...@googlegroups.com

Here's a sample:

require 'ruboto/activity'
require 'ruboto/widget'
require 'ruboto/util/stack'

ruboto_import_widgets :LinearLayout, :ProgressBar, :TextView

$activity.start_ruboto_activity("$pb_test") do
  def on_create(b)
    super
    set_content_view(linear_layout{progress_bar; @text = text_view(:text_size => 40.0)})
    Thread.with_large_stack{do_something}
  end

  def do_something
    10.downto(0){|i| sleep 1; self.run_on_ui_thread{@text.text = i.to_s}}
    self.run_on_ui_thread{done}
  end

  def done
    set_content_view(linear_layout{text_view(:text_size => 40.0,:text => "I'm done!")})
  end
end

Kosmas Chatzimichalis

unread,
Nov 20, 2012, 5:45:18 AM11/20/12
to rub...@googlegroups.com
Hi Scott,

Thanks again for your help!

Great example and it worked fine!
Reply all
Reply to author
Forward
0 new messages