是否有GridView控件setSelectionFromTop(INT位置,int y)对方法 [英] Does have GridView setSelectionFromTop (int position, int y) method
问题描述
我试图调用方法公共无效setSelectionFromTop(INT位置,int y)对
这据此文档中 AbsListView $定义C $ C>自阿比1 <一个href=\"http://developer.android.com/reference/android/widget/AbsListView.html#setSelectionFromTop(int,%20int)\"相对=nofollow> setSelectionFromTop
网格视图扩展AbsListView 公共类GridView的扩展AbsListView
所以这个方法应该在那里。
但我发现了异常运行时 java.lang.NoSuchMethodError
什么奇怪的是,这种方法适用于的ListView
这也延伸 AbsListView
公共类的ListView扩展AbsListView
I'm trying to call method public void setSelectionFromTop (int position, int y)
which accordingly to documentation is defined in AbsListView
since Api 1 setSelectionFromTop
Grid View extends AbsListView public class GridView extends AbsListView
so this method should be there.
But I'm getting Runtime Exception java.lang.NoSuchMethodError
What is strange that this method works for ListView
which also extends AbsListView
public class ListView extends AbsListView
谁能解释一下我这样的行为?
Who can explain me such behavior?
添加
下面是我的code mGridView.setSelectionFromTop(0,scrollHeight属性 - mParallaxViewHeight);
IDE警告我THA这种方法只在21 API提供
Here is my code mGridView.setSelectionFromTop(0, scrollHeight - mParallaxViewHeight);
IDE warns me tha this method is only available in API 21
推荐答案
调用setSelectionFromTop之前投放到GridView的
Cast it to GridView before calling setSelectionFromTop
((GridView) absListView).setSelectionFromTop(...)
或者,如果它是列表视图:
Or if it is Listview:
((ListView) absListView).setSelectionFromTop(...)
这篇关于是否有GridView控件setSelectionFromTop(INT位置,int y)对方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!