I'm working on a menu for my app that is made of a Gallery and sliding it I select a different background image.
gallery.setOnItemSelectedListener(new Gallery.OnItemSelectedListener() {
@Override
public vo开发者_Python百科id onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
imageSwitcher.setImageResource(imm[arg2]);
The idea works decently but the sliding effect is not fluid. My idea is to set a delay, setting:
imageSwitcher.setImageResource(imm[arg2]);
only after a 200ms or so... is something like this possible?
Thank you :) Marco
You can use the Timer and TimerTask class to schedule a operation to happen every 200ms
Something like
Timer scrollTimer = new Timer();
scrollTimer.schedule(
new TimerTask(){
@Override
public void run(){
runOnUiThread(Call the method to do ur work);
}
},
0,200);
精彩评论