【发布时间】:2012-04-10 17:33:49
【问题描述】:
我已经在这个问题上苦苦挣扎了很长时间了。我有 5 个可扩展的列表视图,其中包含一周中每一天的信息,我可以在它们之间滑动。一切正常,除了当我开始活动时,我希望当前列表视图自动向下滚动(而不是用户)到当天。而且..什么也没发生。
SSCCE:
public void Test()
{
for (int i = 0; i < this.numberOfWeeks; i++)
{
// Relative layout to represent the current visible area
RelativeLayout screen = new RelativeLayout(this);
//LayoutParameters for the screen, fills the whole screen
RelativeLayout.LayoutParams newParams = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.FillParent, RelativeLayout.LayoutParams.FillParent);
screen.Id = 1000;
screen.LayoutParameters = newParams;
//An ExpandableListView is created with some parameters not important for this example
ExpandableListView newEListView = this.CreateExpandableListView( //..params..// )
screen.AddView(newEListView);
// Set this newEListView to the array of expandablelistviews
this.expandableListViews[i] = newEListView;
}
// Some more stuff is done, and finally when data is loaded and everything shows up just fine..
// Lets make it automatically scroll down to the current day!
// This does nothing
this.expandableListViews[3].SetSelection(4); // 4 is current day
// Same here
this.expandableListViews[3].SetSelectionFromTop(4, 200);
}
值得一提的是,手动滚动效果很好..
【问题讨论】:
标签: android scroll xamarin.android expandablelistview