花費幾個小時後,我會把我的代碼一些變化,現在它工作正常。之前我使用下面的代碼來附加委託。
ScrollView ScrollView1 = (ScrollView)FindViewById(Resource.Id.ScrollView1);
ScrollView1.ScrollChange += ScrollView1_ScrollChange;
private void ScrollView1_ScrollChange(object sender, EventArgs e)
{
ScrollView scrollView = sender as ScrollView;
double scrollingSpace = scrollView.GetChildAt(0).Height - scrollView.Height;
if (scrollingSpace <= scrollView.ScrollY) // Touched bottom
{
// Do the things you want to do
Toast.MakeText(this, "You have reached to the bottom!", ToastLength.Short).Show();
}
}
現在上面的代碼在幾乎所有的機器上工作,但不是在所有的機器上。很少有機器拋出上述錯誤。 然後,我改變了委託方法PARAMS如下:
void ScrollView1_ScrollChange(object sender, View.ScrollChangeEventArgs e)
現在剩下的定義保持不變。現在這個委託對每臺機器都可以正常工作。
Xamarin Android Player上的Nexus4(KitKat)在使用下面的代理時仍然引發「Java.Lang.ClassNotFoundException:mono.android.view.View_OnScrollChangeListenerImplementor」。 void _scrollView_ScrollChange(object sender,ScrollChangeEventArgs e) –
您能否提一下您的設備的API級別? –
@MasahikoMiyasaka請訪問以下鏈接 http://www.codeproject.com/Articles/1082055/Xamarin-Android-EventHandlers-for-ScrollView-for-E –