Many tx SRI
I solved it by putting the code into it's own method
Viz
Whilst this does not work (code in eventhandler )
t1.Text = "loading";
>
> ThreadPool.QueueUserWorkItem(o
> =>WXclass5.getwindmap(ds, WXclass5.altsel.ToString()));
>
> t1.Text = "";
This does work
ThreadPool.QueueUserWorkItem(o => progbarMethod(ds)); //called
from click eventhandler
//Then
private void probarMethod(string ds)
{
WXclass5.getwindmap2(this,ds);
RunOnUiThread( () =>t1.Text = WXclass5.getaltstring());
RunOnUiThread( () =>i1.SetImageBitmap(WXclass5.windmap));
RunOnUiThread( () =>pb.Visibility=ViewStates.Invisible);
}
-----Original Message-----
From: SRI [mailto:[email protected]]
Sent: 18 September 2011 12:25
To: [email protected]; Discussions related to Mono for Android
Subject: Re: [mono-android] cant get my head around progress bar
Hi
Problem 1 : Showing a Progress Bar
I am doing everything programatically You can also use axml to do
this.
Declare the folowing globally in your activity.
static bool showActivity =false;
ProgressBar _activityIndicator;
private static System.Timers.Timer _periodicTimer ;
In the OnCreate method or where you initialise you views do
the following
_activityIndicator = new ProgressBar(this);
_activityIndicator.Visibility = ViewStates.Invisible;
RelativeLayout.LayoutParams
activityProgressAnimationParams = new RelativeLayout.LayoutParams(100,
100);
activityProgressAnimationParams.AddRule(LayoutRules.CenterHorizontal);
activityProgressAnimationParams.AddRule(LayoutRules.CenterVertical);
[relativeLayout].AddView(_activityIndicator,
activityProgressAnimationParams);
I am adding this to a RelativeLayout View. You may need to
adjust this to what ever is
your main Layout.
Alternative if you have declared this in axml, you can do
the following,
_activityIndicator =
FindViewById<ProgressBar>(Resource.Id.progressBar)
Also initialise the Periodic Timer
_periodicTimer = = new System.Timers.Timer();
_periodicTimer.Elapsed += new
ElapsedEventHandler(PeriodicTimer_Tick);
_periodicTimer.Interval = 500;
Declare the Period Timer Event Handler
private void PeriodicTimer_Tick(object sender, ElapsedEventArgs e)
{
}
On Sat, Sep 17, 2011 at 6:32 PM, John Murray <[email protected]> wrote:
> Ive cracked a number of things along the learning curve of Mandroid but I
> am being really thick here
>
> I just cannot get my head around the implementation of a progress bar
can
> some kind soul help me with some idiot proof code?
>
>
>
> I have a static class method which fetches some meteorological diagrams
from
> a webserver and places resulting bitmap in a static which is later
accessed
> by an imageview
>
> Takes 4 or 5 seconds but a lot longer over a GSM network therefore I want
to
> put up a progress thingy
>
>
>
> For the time being Ive got a textview just saying loading
>
>
>
> These lines of code are called when a user selects something from a
> spinner
>
> Obviously this doesnt do much
>
> t1.Text = "loading";
>
> WXclass5.getwindmap(ds, WXclass5.altsel.ToString());
>
> t1.Text = "";
>
> but why cant I do this
>
> t1.Text = "loading";
>
> ThreadPool.QueueUserWorkItem(o
> =>WXclass5.getwindmap(ds, WXclass5.altsel.ToString()));
>
> t1.Text = "";
>
> theres no UI code in the getwindmap just a webclient call and some
> bitmap/byte manipulation
>
> but implementing the threadpool.QueueWorkItem does not seem to fetch
> anything or do anything I cant seem to debug into it to see whats
> happening (is there a special method of debugging on separate threads?
>
>
>
> With regards to implementing the progress bar instead of text saying
loading
> I presume I just replace the text.t1 with a progressbar -and set it
> visible before the threadpoolqueue and non-visible after?
>
>
>
> I suspect it is not that simple
>
>
>
> Sorry to seem so stupid but Ive read all the android stuff on
progressbars
> and Ive developed a complete mental block the more I read the less I
> understand.
>
> Can someone please explain in baby language please?
>
>
>
>
>
> _______________________________________________
> Monodroid mailing list
> [email protected]
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
>
>
--
Sridharan Srinivasan
Alias Sri
Ph:(65)98255785/(65)63922439
www.arshu.com
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid