On Fri, Jan 27, 2012 at 3:38 PM, Oliviu Vais <[email protected]> wrote:
> I got this far, but this doesn't work.
You should generally explain what "doesn't work" means, but I can tell from
your code that you're locking the UI and getting an ANR, right?
You can't just do "while (some condition that has just been set to true)"
within the main thread. That puts you in an infinite loop and gets you
stuck. You need to do something like this:
onMotionEvent(View view)
{
if (action down)
{
// Pressed down on a button, save it and start the scroll timer
(onTimerTick)
viewClicked = view;
startScrollTimer();
}
else if (action up)
stopScrollTimer(); // Released the button, stop the timer (and thus the
scrolling)
}
onTimerTicker()
{
if (viewClicked == left)
scrollLeft();
else if (viewClicked == right)
scrollRight();
}
There are multiple ways to do the timer logic, Kostya showed you one.
-------------------------------------------------------------------------------------------------
TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
transit tracking app for Android-powered devices
--
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