开发者

values for direction parameter in arrowScroll function of ScrollView Class

I开发者_如何学JAVA need to scroll the ScrollView dynamically to up and down by click a button for that purpose i am using arrowScroll(int direction) method.

But i don't which values i have to give for the direction parameter for up and down direction.


Note that if the user has a direction pad, then the ScrollView is scrollable "out of the box" with minimal effort on the developer's part. Also, if you just want to map different keys to ScrollView navigation, then take a look at ScrollView's boolean executeKeyEvent(KeyEvent) method.

With that said...

At your prompting, I was also curious about this. So, I jumped on Google, found the ScrollView source code, and looked at the code for boolean arrowScroll(int). That code is looking for the following direction values:

  • View.FOCUS_UP = 33
  • View.FOCUS_DOWN = 130

This of course doesn't answer how horizontal scrolling would work. Poking around in the code some more might provide that information.


Well, @Thane has answered the question. I did not have to poke around much. Tried View.FOCUS_RIGHT and View.FOCUS_LEFT to scroll right and left resp. and got lucky :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜