【问题标题】:Android: How to invoke programmatically onScroll event in ListViewAndroid:如何在 ListView 中以编程方式调用 onScroll 事件
【发布时间】:2011-05-27 12:37:35
【问题描述】:

我正在尝试在 ListView 中以编程方式调用 onScroll 事件。

谁能帮帮我?

这是我的代码:

@RunWith(RobolectricTestRunner.class)
public class ActivityListViewTest {

    private ActivityListView activity;

    @Before
    public void setUp() throws Exception {
        activity = new ActivityListView();
    }

    @Test
    public void shouldUpdateListViewChildCountOnCreate() throws Exception{
        activity.onCreate(null);
        ListView calendarListView = (ListView)activity.findViewById(R.id.listview);

        assertTrue("CHILD COUNT IS: " + calendarListView.getChildCount(), calendarListView.getChildCount() > 0);

        // Here i want to invoke onScroll event. Then ListView must update and listView items count become to be more that 20

        assertTrue("CHILD COUNT IS: " + calendarListView.getChildCount(), calendarListView.getChildCount() > 20);
    }
}

【问题讨论】:

  • 添加你正在使用的代码...

标签: android events onscroll


【解决方案1】:

来自official documentation

public void smoothScrollByOffset (int offset) 

public void smoothScrollToPosition (int position) 

【讨论】:

    猜你喜欢
    • 2010-10-04
    • 2010-11-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-16
    • 2014-12-05
    相关资源
    最近更新 更多