I am sorry for the lack of clarity. I posted only the code snippets as it
might be really difficult to read the entire code. I am trying to update
this thread from the main activity.

Let me post a condensed version:

public class MyProgressBar extends LinearLayout implements Runnable {

.......


........
public void Message(String Message)
 {
    String r = Message;
    try {
        myNum = Integer.parseInt(r);
    } catch(NumberFormatException nfe) {
    }
   m = (myNum/100);
   if(m>=8)
   {
   m=1;
   }

}
/**

@Override
 public void run() {
while (stopped) {
try {
 // Sleep for 0.3 secs and after that change the images
Thread.sleep(100);
 handler.sendEmptyMessage(0);
} catch (InterruptedException e) {
e.printStackTrace();
 }
}
}

private Handler handler = new Handler() {

@Override
 public void handleMessage(Message msg) {
int currentImage = 0;
int nextImage = 0;
 if(i<=m)
{
i++;
 }
else
{
 i=1;
for(int j=0;j<9;j++)
{
 ImageView imageView1 =imageHolders.get(j);

imageView1.setVisibility(View.GONE);

}
}
 // Logic to change the images
ImageView imageView =imageHolders.get(i-1);
 {
      imageView.setVisibility(View.VISIBLE);

}
 super.handleMessage(msg);
}

};
  }



Thanks,
Sai



On Sun, Jul 8, 2012 at 12:49 AM, G. Blake Meike <[email protected]>wrote:

> I really can't figure out what you are asking here.  There's no evidence
> or a runnable. I'm guessing that m and myNum are data members?  Are they
> being updated from two different threads?
>
> G. Blake Meike
> Marakana
>
> The second edition of Programming Android is now on-line:
> http://shop.oreilly.com/product/0636920023005.do
>
> On Saturday, July 7, 2012 7:14:22 PM UTC-7, yamanoorsai wrote:
>>
>> Hi,
>>
>> I have a runnable in my app that runs an animation. I would like to
>> update a variable so that animation varies according to the data from
>> bluetooth.
>>
>> This is the function that reads the string in the runnable:
>>
>> public void Message(String Message)
>>>  {
>>>     String r = Message;
>>>     try {
>>>         myNum = Integer.parseInt(r);
>>>     } catch(NumberFormatException nfe) {
>>>     }
>>>    m = (myNum/100);
>>>    if(m>=8)
>>>    {
>>>    m=1;
>>>    }
>>> }
>>
>>
>> This is how I am calling the runnable in the main activity:
>>
>> pBar.Message(message).
>>
>>
>> It takes at least a minute to update the string in the runnable and it
>> happens only once. I am not able to pass a string to the runnable. Any
>> suggestions to pass a string to a runnable would be greatly appreciated.
>>
>>
>> Sai
>>
>  --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to