有沒有一種方法可以在列表視圖上以編程方式執行一個Fling?我知道有猴子會做所有這些事情,但需要與adb等電腦連接等。我想用我的應用程序在任何手機上完成,沒有猴子。以編程方式扔掉ListView Android
感謝, 費薩爾
有沒有一種方法可以在列表視圖上以編程方式執行一個Fling?我知道有猴子會做所有這些事情,但需要與adb等電腦連接等。我想用我的應用程序在任何手機上完成,沒有猴子。以編程方式扔掉ListView Android
感謝, 費薩爾
可以僞造其與動畫(我認爲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
有兩種方法「平滑滾動」而不是跳轉到某個位置。
退房http://developer.android.com/reference/android/widget/ScrollView.html
爲smoothScrollBy()
和smoothScrollTo()
。
希望這會有所幫助。
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);
}
嘿盧卡斯,你有一段代碼,我很困惑。 謝謝, 費薩爾 – 2009-08-01 04:19:41
你好,我增加了更多的信息,將幫助你。 – 2009-08-03 14:19:37