我一直在努力解决这个问题ridiculos现在的时间量。我有5个可扩展的列表视图,其中包含每周的每一天的信息,我可以在它们之间滑动。一切正常,除非当我开始活动,我希望当前列表视图自动滚动(不是由用户)到当天。并且..假设发生了。ExpandableListView不能自动滚动
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);
}
可能是值得一提的是手动滚动工作得很好..
恐怕Monodroid中没有这种方法.. :( – 2012-03-27 09:49:39
http://androidapi.xamarin.com/?link=M%3aAndroid.Widget.AbsListView.SmoothScrollToPosition%28System.Int32%29 – jpobst 2012-03-27 14:19:03