2009-07-31 64 views
5

有没有一种方法可以在列表视图上以编程方式执行一个Fling?我知道有猴子会做所有这些事情,但需要与adb等电脑连接等。我想用我的应用程序在任何手机上完成,没有猴子。以编程方式扔掉ListView Android

感谢, 费萨尔

回答

-1

可以伪造其与动画(我认为accelerate_decelerate_interpolator可以做的工作)。

而且似乎有一种通过自己的滚动视图支持:

public void scrollBy (int x, int y) 

移动视图的滚动位置。这将导致对onScrollChanged(int,int,int,int)的调用,视图将失效。

Parameters 
x the amount of pixels to scroll by horizontally 
y the amount of pixels to scroll by vertically 
public void scrollTo (int x, int y) 

设置您的视图的滚动位置。这将导致对onScrollChanged(int,int,int,int)的调用,视图将失效。

 
Parameters 
x the x position to scroll to 
y the y position to scroll to 
+0

嘿卢卡斯,你有一段代码,我很困惑。 谢谢, 费萨尔 – 2009-08-01 04:19:41

+1

你好,我增加了更多的信息,将帮助你。 – 2009-08-03 14:19:37

1
private AnimationSet set; 

public void onClick(View v) { 
    if(v.getId() == R.id.pullbutton){ 
     artListview.setVisibility(View.INVISIBLE); 
     if(set == null){ 
      set = new AnimationSet(true); 
      Animation animation = new AlphaAnimation(0.0f, 1.0f); 
      animation.setDuration(100); 
      set.addAnimation(animation); 

      animation = new TranslateAnimation(
        Animation.RELATIVE_TO_SELF, 0.0f, 
        Animation.RELATIVE_TO_SELF, 0.0f,    
        Animation.RELATIVE_TO_SELF, -1.0f, 
        Animation.RELATIVE_TO_SELF, 0.0f 
      ); 
      animation.setDuration(1000); 
      set.addAnimation(animation); 
     } 
     showPullDownSectionList(); 
    } 

} 


public void showPullDownSectionList() { 
    flipper = (ViewFlipper) findViewById(R.id.ViewFlipper01); 
    flipper.setVisibility(View.VISIBLE); 
    setLayoutAnim_slidedownfromtop(flipper); 
} 

public void setLayoutAnim_slidedownfromtop(ViewFlipper flipper) { 
    LayoutAnimationController controller = 
     new LayoutAnimationController(set, 0.25f); 
    flipper.setLayoutAnimation(controller); 

}