2009-07-31 25 views
5

Có cách nào tôi có thể lập trình thực hiện một Fling trên listview? Tôi biết có khỉ mà làm tất cả những điều này nhưng điều đó đòi hỏi một kết nối máy tính với adb vv vv Tôi muốn làm điều đó với ứng dụng của tôi trên bất kỳ điện thoại, không có con khỉ.Lập trình Danh sách FlingView Android

Cảm ơn, Faisal

Trả lời

-1

Bạn có thể giả mạo nó với một anim (tôi nghĩ rằng accelerate_decelerate_interpolator có thể thực hiện công việc).

Cũng có vẻ như có sự ủng hộ để di chuyển tầm nhìn của bạn bằng cách riêng của bạn:

public void scrollBy (int x, int y) 

Di chuyển vị trí cuộn của tầm nhìn của bạn. Điều này sẽ gây ra một cuộc gọi đến onScrollChanged (int, int, int, int) và khung nhìn sẽ bị vô hiệu.

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) 

Đặt vị trí cuộn của tầm nhìn của bạn. Điều này sẽ gây ra một cuộc gọi đến onScrollChanged (int, int, int, int) và khung nhìn sẽ bị vô hiệu.

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

Hey Lucas, bạn có đoạn mã không, tôi khá bối rối. Cảm ơn, Faisal –

+1

Xin chào, tôi đã thêm thông tin khác sẽ giúp bạn. –

+0

Cảm ơn người đàn ông tôi không biết điều này! –

2

Có hai phương pháp để "cuộn trơn tru" thay vì chuyển đến vị trí.

Check-out http://developer.android.com/reference/android/widget/ScrollView.html

cho smoothScrollBy()smoothScrollTo().

Hy vọng điều này sẽ hữu ích.

+0

Bạn đang đề cập đến scrollview và câu hỏi là cho một listview. Listview cũng có một số tính năng gọn gàng: smootScrollToPosition và smootScrollByOffset. Tuy nhiên, chúng chỉ có sẵn ở cấp api 8 và 11 tương ứng. http://developer.android.com/reference/android/widget/ListView.html#smoothScrollToPosition (int) –

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); 

} 
Các vấn đề liên quan