如何解决Android:如何在ListView中以编程方式调用onScroll事件
|| 我试图以编程方式在ListView中调用“ 0”事件。 有谁能够帮助我? 这是我的代码:@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);
}
}
解决方法
从官方文档中:
public void smoothScrollByOffset (int offset)
要么
public void smoothScrollToPosition (int position)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。