2012-03-07 10 views
6

Chcę, aby po dotarciu do końca, prawy przycisk zmieni kolor, gdy osiągnie początek, lewy przycisk zmieni kolor, więc chcę zapytać, jak to wykryć HorizontalScrollView osiągnął koniec.Jak wykryć, że HorizontalScrollView osiągnął koniec

+1

ten link pomoże: [http://stackoverflow.com/questions/2089552/android-how-to-detect-when-a-scroll-has-ended][1] [1]: http://stackoverflow.com/questions/2089552/android-how-to-detect-when-a-scroll-has-ended –

+0

[ten post może pomóc] (http: //stackoverflow.com/a/3952629/593709) –

+0

maxScrollX = horizontalScrollView.getChildAt (0) \t \t .getMeasured Width() - horizontalScrollView.getMeasuredWidth(); if (horizontalScrollView.getScrollX() == 0) { \t \t \t \t \t lImageView.setImageResource (R.drawable.left_green); \t \t \t \t} else { \t \t \t \t \t lImageView.setImageResource (R.drawable.left); \t \t \t \t} \t \t \t \t if (horizontalScrollView.getScrollX() == maxScrollX) { \t \t \t \t \t rImageView.setImageResource (R.drawable.right_green); \t \t \t \t} else { \t \t \t \t \t rImageView.setImageResource (R.drawable.right); \t \t \t \t} – jack

Odpowiedz

12
maxScrollX = horizontalScrollView.getChildAt(0).getMeasuredWidth()-horizontalScrollView.getMeasuredWidth(); 
    if (horizontalScrollView.getScrollX() == 0) { 
     lImageView.setImageResource(R.drawable.left_green); 
    } else { 
     lImageView.setImageResource(R.drawable.left); 
    } 

    if (horizontalScrollView.getScrollX() == maxScrollX) { 
     rImageView.setImageResource(R.drawable.right_green); 
    } else { 
     rImageView.setImageResource(R.drawable.right); 
    } 
+2

Gdzie wystrzelić to wydarzenie - każdy słuchacz? – NarendraJi

Powiązane problemy